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 void
contains(Collection collection, Object value)
Check that the collection contains the valuestatic void
contains(Collection collection, Object value, String message)
Check that the collection contains the valuestatic void
containsKey(Map map, Object key)
Check that the map contains the keystatic void
containsKey(Map map, Object key, String message)
Check that the map contains the keystatic void
isInstanceOf(Class theClass, Object value)
Check that the object is an instance of the specified Classstatic void
isInstanceOf(Class theClass, Object value, String message)
Check that the object is an instance of the specified Classstatic void
isNegative(int value)
Check that the value is negative (<0).static void
isNegative(int value, String message)
Check that the value is negative (<0).static void
isNegative(long value)
Check that the value is negative (<0).static void
isNegative(long value, String message)
Check that the value is negative (<0).static void
isNonNegative(int value)
Check that the value is non-negative (>=0).static void
isNonNegative(int value, String message)
Check that the value is non-negative (>=0).static void
isNonNegative(long value)
Check that the value is non-negative (>=0).static void
isNonNegative(long value, String message)
Check that the value is non-negative (>=0).static void
isNonPositive(int value)
Check that the value is non-positive (<=0).static void
isNonPositive(int value, String message)
Check that the value is non-positive (<=0).static void
isNonPositive(long value)
Check that the value is non-positive (<=0).static void
isNonPositive(long value, String message)
Check that the value is non-positive (<=0).static void
isNotEmpty(Object[] array)
Check that the array is not emptystatic void
isNotEmpty(Object[] array, String message)
Check that the array is not emptystatic void
isNotEmpty(String string)
Check that the string is not emptystatic void
isNotEmpty(String string, String message)
Check that the string is not emptystatic void
isNotEmpty(Collection collection)
Check that the collection is not emptystatic void
isNotEmpty(Collection collection, String message)
Check that the collection is not emptystatic void
isNotEmpty(Map map)
Check that the map is not emptystatic void
isNotEmpty(Map map, String message)
Check that the map is not emptystatic void
isNotNull(Object value)
Check that the object is non-nullstatic void
isNotNull(Object value, String message)
Check that the object is non-nullstatic 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.static void
isNotZeroLength(String value)
Check that the string is non-null and has length > 0static void
isNotZeroLength(String value, String message)
Check that the string is non-null and has length > 0static void
isNull(Object value)
Check that the object is nullstatic void
isNull(Object value, String message)
Check that the object is nullstatic void
isPositive(int value)
Check that the value is positive (>0).static void
isPositive(int value, String message)
Check that the value is positive (>0).static void
isPositive(long value)
Check that the value is positive (>0).static void
isPositive(long value, String message)
Check that the value is positive (>0).static void
isTrue(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 andfirstObject
is 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 andsecondObject
is 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
-
-