Package org.teiid.core.util
Class ArgCheck
- java.lang.Object
-
- org.teiid.core.util.ArgCheck
-
public class ArgCheck extends Object
This class contains a set of static utility methods for checking method arguments. It contains many of the common checks that are done, such as checking that an Object is non-null, checking the range of a value, etc. All of these methods throwIllegalArgumentException.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcontains(Collection collection, Object value)Check that the collection contains the valuestatic voidcontains(Collection collection, Object value, String message)Check that the collection contains the valuestatic voidcontainsKey(Map map, Object key)Check that the map contains the keystatic voidcontainsKey(Map map, Object key, String message)Check that the map contains the keystatic voidisInstanceOf(Class theClass, Object value)Check that the object is an instance of the specified Classstatic voidisInstanceOf(Class theClass, Object value, String message)Check that the object is an instance of the specified Classstatic voidisNegative(int value)Check that the value is negative (<0).static voidisNegative(int value, String message)Check that the value is negative (<0).static voidisNegative(long value)Check that the value is negative (<0).static voidisNegative(long value, String message)Check that the value is negative (<0).static voidisNonNegative(int value)Check that the value is non-negative (>=0).static voidisNonNegative(int value, String message)Check that the value is non-negative (>=0).static voidisNonNegative(long value)Check that the value is non-negative (>=0).static voidisNonNegative(long value, String message)Check that the value is non-negative (>=0).static voidisNonPositive(int value)Check that the value is non-positive (<=0).static voidisNonPositive(int value, String message)Check that the value is non-positive (<=0).static voidisNonPositive(long value)Check that the value is non-positive (<=0).static voidisNonPositive(long value, String message)Check that the value is non-positive (<=0).static voidisNotEmpty(Object[] array)Check that the array is not emptystatic voidisNotEmpty(Object[] array, String message)Check that the array is not emptystatic voidisNotEmpty(String string)Check that the string is not emptystatic voidisNotEmpty(String string, String message)Check that the string is not emptystatic voidisNotEmpty(Collection collection)Check that the collection is not emptystatic voidisNotEmpty(Collection collection, String message)Check that the collection is not emptystatic voidisNotEmpty(Map map)Check that the map is not emptystatic voidisNotEmpty(Map map, String message)Check that the map is not emptystatic voidisNotNull(Object value)Check that the object is non-nullstatic voidisNotNull(Object value, String message)Check that the object is non-nullstatic voidisNotSame(Object firstObject, String firstName, Object secondObject, String secondName)Asserts that the specified first object is not the same as (==) the specified second object.static voidisNotZeroLength(String value)Check that the string is non-null and has length > 0static voidisNotZeroLength(String value, String message)Check that the string is non-null and has length > 0static voidisNull(Object value)Check that the object is nullstatic voidisNull(Object value, String message)Check that the object is nullstatic voidisPositive(int value)Check that the value is positive (>0).static voidisPositive(int value, String message)Check that the value is positive (>0).static voidisPositive(long value)Check that the value is positive (>0).static voidisPositive(long value, String message)Check that the value is positive (>0).static voidisTrue(boolean condition, String message)Check that the boolean condition is true; throw an IllegalArgumentException if not.
-
-
-
Method Detail
-
isTrue
public static final void isTrue(boolean condition, String message)Check that the boolean condition is true; throw an IllegalArgumentException if not.- Parameters:
condition- The boolean condition to checkmessage- Exception message if check fails- Throws:
IllegalArgumentException- if condition is false
-
isNonNegative
public static final void isNonNegative(int value)
Check that the value is non-negative (>=0).- Parameters:
value- Value- Throws:
IllegalArgumentException- If value is negative (<0)
-
isNonNegative
public static final void isNonNegative(int value, String message)Check that the value is non-negative (>=0).- Parameters:
value- Valuemessage- Exception message if check fails- Throws:
IllegalArgumentException- If value is negative (<0)
-
isNonPositive
public static final void isNonPositive(int value)
Check that the value is non-positive (<=0).- Parameters:
value- Value- Throws:
IllegalArgumentException- If value is positive (>0)
-
isNonPositive
public static final void isNonPositive(int value, String message)Check that the value is non-positive (<=0).- Parameters:
value- Valuemessage- Exception message if check fails- Throws:
IllegalArgumentException- If value is positive (>0)
-
isNegative
public static final void isNegative(int value)
Check that the value is negative (<0).- Parameters:
value- Value- Throws:
IllegalArgumentException- If value is non-negative (>=0)
-
isNegative
public static final void isNegative(int value, String message)Check that the value is negative (<0).- Parameters:
value- Valuemessage- Exception message if check fails- Throws:
IllegalArgumentException- If value is non-negative (>=0)
-
isPositive
public static final void isPositive(int value)
Check that the value is positive (>0).- Parameters:
value- Value- Throws:
IllegalArgumentException- If value is non-positive (<=0)
-
isPositive
public static final void isPositive(int value, String message)Check that the value is positive (>0).- Parameters:
value- Valuemessage- Exception message if check fails- Throws:
IllegalArgumentException- If value is non-positive (<=0)
-
isNonNegative
public static final void isNonNegative(long value)
Check that the value is non-negative (>=0).- Parameters:
value- Value- Throws:
IllegalArgumentException- If value is negative (<0)
-
isNonNegative
public static final void isNonNegative(long value, String message)Check that the value is non-negative (>=0).- Parameters:
value- Valuemessage- Exception message if check fails- Throws:
IllegalArgumentException- If value is negative (<0)
-
isNonPositive
public static final void isNonPositive(long value)
Check that the value is non-positive (<=0).- Parameters:
value- Value- Throws:
IllegalArgumentException- If value is positive (>0)
-
isNonPositive
public static final void isNonPositive(long value, String message)Check that the value is non-positive (<=0).- Parameters:
value- Valuemessage- Exception message if check fails- Throws:
IllegalArgumentException- If value is positive (>0)
-
isNegative
public static final void isNegative(long value)
Check that the value is negative (<0).- Parameters:
value- Value- Throws:
IllegalArgumentException- If value is non-negative (>=0)
-
isNegative
public static final void isNegative(long value, String message)Check that the value is negative (<0).- Parameters:
value- Valuemessage- Exception message if check fails- Throws:
IllegalArgumentException- If value is non-negative (>=0)
-
isPositive
public static final void isPositive(long value)
Check that the value is positive (>0).- Parameters:
value- Value- Throws:
IllegalArgumentException- If value is non-positive (<=0)
-
isPositive
public static final void isPositive(long value, String message)Check that the value is positive (>0).- Parameters:
value- Valuemessage- Exception message if check fails- Throws:
IllegalArgumentException- If value is non-positive (<=0)
-
isNotZeroLength
public static final void isNotZeroLength(String value)
Check that the string is non-null and has length > 0- Parameters:
value- Value- Throws:
IllegalArgumentException- If value is null or length == 0
-
isNotZeroLength
public static final void isNotZeroLength(String value, String message)
Check that the string is non-null and has length > 0- Parameters:
value- Valuemessage- Exception message if check fails- Throws:
IllegalArgumentException- If value is null or length == 0
-
isNotNull
public static final void isNotNull(Object value)
Check that the object is non-null- Parameters:
value- Value- Throws:
IllegalArgumentException- If value is null
-
isNotNull
public static final void isNotNull(Object value, String message)
Check that the object is non-null- Parameters:
value- Valuemessage- Exception message if check fails- Throws:
IllegalArgumentException- If value is null
-
isNull
public static final void isNull(Object value)
Check that the object is null- Parameters:
value- Value- Throws:
IllegalArgumentException- If value is non-null
-
isNull
public static final void isNull(Object value, String message)
Check that the object is null- Parameters:
value- Valuemessage- Exception message if check fails- Throws:
IllegalArgumentException- If value is non-null
-
isInstanceOf
public static final void isInstanceOf(Class theClass, Object value)
Check that the object is an instance of the specified Class- Parameters:
theClass- Classvalue- Value- Throws:
IllegalArgumentException- If value is null
-
isInstanceOf
public static final void isInstanceOf(Class theClass, Object value, String message)
Check that the object is an instance of the specified Class- Parameters:
theClass- Classvalue- Valuemessage- Exception message if check fails- Throws:
IllegalArgumentException- If value is null
-
isNotEmpty
public static final void isNotEmpty(Collection collection)
Check that the collection is not empty- Parameters:
collection- Collection- Throws:
IllegalArgumentException- If collection is null or empty
-
isNotEmpty
public static final void isNotEmpty(Collection collection, String message)
Check that the collection is not empty- Parameters:
collection- Collectionmessage- Exception message if check fails- Throws:
IllegalArgumentException- If collection is null or empty
-
isNotEmpty
public static final void isNotEmpty(Map map)
Check that the map is not empty- Parameters:
map- Map- Throws:
IllegalArgumentException- If map is null or empty
-
isNotEmpty
public static final void isNotEmpty(Map map, String message)
Check that the map is not empty- Parameters:
map- Mapmessage- Exception message if check fails- Throws:
IllegalArgumentException- If map is null or empty
-
isNotEmpty
public static final void isNotEmpty(Object[] array)
Check that the array is not empty- Parameters:
array- Array- Throws:
IllegalArgumentException- If array is null or empty- Since:
- 3.1
-
isNotEmpty
public static final void isNotEmpty(Object[] array, String message)
Check that the array is not empty- Parameters:
array- Arraymessage- Exception message if check fails- Throws:
IllegalArgumentException- If array is null or empty- Since:
- 3.1
-
isNotEmpty
public static final void isNotEmpty(String string)
Check that the string is not empty- Parameters:
string- String- Throws:
IllegalArgumentException- If string is null or empty- Since:
- 3.1
-
isNotEmpty
public static final void isNotEmpty(String string, String message)
Check that the string is not empty- Parameters:
string- Stringmessage- Exception message if check fails- Throws:
IllegalArgumentException- If string is null or empty- Since:
- 3.1
-
isNotSame
public static void isNotSame(Object firstObject, String firstName, Object secondObject, String secondName)
Asserts that the specified first object is not the same as (==) the specified second object.- Parameters:
firstObject- The first object to assert as not the same as the second object.firstName- The name that will be used within the exception message for the first object, should an exception be thrown; if null andfirstObjectis not null,firstObject.toString()will be used.secondObject- The second object to assert as not the same as the first object.secondName- The name that will be used within the exception message for the second object, should an exception be thrown; if null andsecondObjectis not null,secondObject.toString()will be used.- Throws:
IllegalArgumentException- If the specified objects are the same.- Since:
- 3.1
-
contains
public static final void contains(Collection collection, Object value)
Check that the collection contains the value- Parameters:
collection- Collection to checkvalue- Value to check for, may be null- Throws:
IllegalArgumentException- If collection is null or doesn't contain value
-
contains
public static final void contains(Collection collection, Object value, String message)
Check that the collection contains the value- Parameters:
collection- Collection to checkvalue- Value to check for, may be nullmessage- Exception message if check fails- Throws:
IllegalArgumentException- If collection is null or doesn't contain value
-
containsKey
public static final void containsKey(Map map, Object key)
Check that the map contains the key- Parameters:
map- Map to checkkey- Key to check for, may be null- Throws:
IllegalArgumentException- If map is null or doesn't contain key
-
containsKey
public static final void containsKey(Map map, Object key, String message)
Check that the map contains the key- Parameters:
map- Map to checkkey- Key to check for, may be nullmessage- Exception message if check fails- Throws:
IllegalArgumentException- If map is null or doesn't contain key
-
-