1 17 package org.alfresco.util; 18 19 import java.util.Collection ; 20 21 26 public class ParameterCheck 27 { 28 34 public static void mandatory(String strParamName, Object object) 35 { 36 if (strParamName == null || strParamName.length() == 0) 37 { 38 throw new IllegalArgumentException ("Parameter name is mandatory"); 39 } 40 41 if (object == null) 43 { 44 throw new IllegalArgumentException (strParamName + " is a mandatory parameter"); 45 } 46 } 47 48 55 public static void mandatoryString(String strParamName, String strParamValue) 56 { 57 if (strParamName == null || strParamName.length() == 0) 58 { 59 throw new IllegalArgumentException ("Parameter name is mandatory"); 60 } 61 62 if (strParamValue == null || strParamValue.length() == 0) 64 { 65 throw new IllegalArgumentException (strParamName + " is a mandatory parameter"); 66 } 67 } 68 69 70 76 public static void mandatoryCollection(String strParamName, Collection coll) 77 { 78 if (strParamName == null || strParamName.length() == 0) 79 { 80 throw new IllegalArgumentException ("Parameter name is mandatory"); 81 } 82 83 if (coll == null || coll.size() == 0) 84 { 85 throw new IllegalArgumentException (strParamName + " collection must contain at least one item"); 86 } 87 } 88 89 } 90 | Popular Tags |