|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.metamatrix.core.util.ArgCheck
public class ArgCheck
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
throw #java.lang.IllegalArgumentException
.
Method Summary | |
---|---|
static void |
contains(java.util.Collection collection,
java.lang.Object value)
Check that the collection contains the value |
static void |
contains(java.util.Collection collection,
java.lang.Object value,
java.lang.String message)
Check that the collection contains the value |
static void |
containsKey(java.util.Map map,
java.lang.Object key)
Check that the map contains the key |
static void |
containsKey(java.util.Map map,
java.lang.Object key,
java.lang.String message)
Check that the map contains the key |
static void |
isInstanceOf(java.lang.Class theClass,
java.lang.Object value)
Check that the object is an instance of the specified Class |
static void |
isInstanceOf(java.lang.Class theClass,
java.lang.Object value,
java.lang.String message)
Check that the object is an instance of the specified Class |
static void |
isNegative(int value)
Check that the value is negative (<0). |
static void |
isNegative(int value,
java.lang.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,
java.lang.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,
java.lang.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,
java.lang.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,
java.lang.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,
java.lang.String message)
Check that the value is non-positive (<=0). |
static void |
isNotEmpty(java.util.Collection collection)
Check that the collection is not empty |
static void |
isNotEmpty(java.util.Collection collection,
java.lang.String message)
Check that the collection is not empty |
static void |
isNotEmpty(java.util.Map map)
Check that the map is not empty |
static void |
isNotEmpty(java.util.Map map,
java.lang.String message)
Check that the map is not empty |
static void |
isNotEmpty(java.lang.Object[] array)
Check that the array is not empty |
static void |
isNotEmpty(java.lang.Object[] array,
java.lang.String message)
Check that the array is not empty |
static void |
isNotEmpty(java.lang.String string)
Check that the string is not empty |
static void |
isNotEmpty(java.lang.String string,
java.lang.String message)
Check that the string is not empty |
static void |
isNotNull(java.lang.Object value)
Check that the object is non-null |
static void |
isNotNull(java.lang.Object value,
java.lang.String message)
Check that the object is non-null |
static void |
isNotSame(java.lang.Object firstObject,
java.lang.String firstName,
java.lang.Object secondObject,
java.lang.String secondName)
Asserts that the specified first object is not the same as (==) the specified second object. |
static void |
isNotZeroLength(java.lang.String value)
Check that the string is non-null and has length > 0 |
static void |
isNotZeroLength(java.lang.String value,
java.lang.String message)
Check that the string is non-null and has length > 0 |
static void |
isNull(java.lang.Object value)
Check that the object is null |
static void |
isNull(java.lang.Object value,
java.lang.String message)
Check that the object is null |
static void |
isPositive(int value)
Check that the value is positive (>0). |
static void |
isPositive(int value,
java.lang.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,
java.lang.String message)
Check that the value is positive (>0). |
static void |
isTrue(boolean condition,
java.lang.String message)
Check that the boolean condition is true; throw an IllegalArgumentException if not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static final void isTrue(boolean condition, java.lang.String message)
condition
- The boolean condition to checkmessage
- Exception message if check fails
java.lang.IllegalArgumentException
- if condition is falsepublic static final void isNonNegative(int value)
value
- Value
java.lang.IllegalArgumentException
- If value is negative (<0)public static final void isNonNegative(int value, java.lang.String message)
value
- Valuemessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If value is negative (<0)public static final void isNonPositive(int value)
value
- Value
java.lang.IllegalArgumentException
- If value is positive (>0)public static final void isNonPositive(int value, java.lang.String message)
value
- Valuemessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If value is positive (>0)public static final void isNegative(int value)
value
- Value
java.lang.IllegalArgumentException
- If value is non-negative (>=0)public static final void isNegative(int value, java.lang.String message)
value
- Valuemessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If value is non-negative (>=0)public static final void isPositive(int value)
value
- Value
java.lang.IllegalArgumentException
- If value is non-positive (<=0)public static final void isPositive(int value, java.lang.String message)
value
- Valuemessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If value is non-positive (<=0)public static final void isNonNegative(long value)
value
- Value
java.lang.IllegalArgumentException
- If value is negative (<0)public static final void isNonNegative(long value, java.lang.String message)
value
- Valuemessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If value is negative (<0)public static final void isNonPositive(long value)
value
- Value
java.lang.IllegalArgumentException
- If value is positive (>0)public static final void isNonPositive(long value, java.lang.String message)
value
- Valuemessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If value is positive (>0)public static final void isNegative(long value)
value
- Value
java.lang.IllegalArgumentException
- If value is non-negative (>=0)public static final void isNegative(long value, java.lang.String message)
value
- Valuemessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If value is non-negative (>=0)public static final void isPositive(long value)
value
- Value
java.lang.IllegalArgumentException
- If value is non-positive (<=0)public static final void isPositive(long value, java.lang.String message)
value
- Valuemessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If value is non-positive (<=0)public static final void isNotZeroLength(java.lang.String value)
value
- Value
java.lang.IllegalArgumentException
- If value is null or length == 0public static final void isNotZeroLength(java.lang.String value, java.lang.String message)
value
- Valuemessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If value is null or length == 0public static final void isNotNull(java.lang.Object value)
value
- Value
java.lang.IllegalArgumentException
- If value is nullpublic static final void isNotNull(java.lang.Object value, java.lang.String message)
value
- Valuemessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If value is nullpublic static final void isNull(java.lang.Object value)
value
- Value
java.lang.IllegalArgumentException
- If value is non-nullpublic static final void isNull(java.lang.Object value, java.lang.String message)
value
- Valuemessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If value is non-nullpublic static final void isInstanceOf(java.lang.Class theClass, java.lang.Object value)
theClass
- Classvalue
- Value
java.lang.IllegalArgumentException
- If value is nullpublic static final void isInstanceOf(java.lang.Class theClass, java.lang.Object value, java.lang.String message)
theClass
- Classvalue
- Valuemessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If value is nullpublic static final void isNotEmpty(java.util.Collection collection)
collection
- Collection
java.lang.IllegalArgumentException
- If collection is null or emptypublic static final void isNotEmpty(java.util.Collection collection, java.lang.String message)
collection
- Collectionmessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If collection is null or emptypublic static final void isNotEmpty(java.util.Map map)
map
- Map
java.lang.IllegalArgumentException
- If map is null or emptypublic static final void isNotEmpty(java.util.Map map, java.lang.String message)
map
- Mapmessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If map is null or emptypublic static final void isNotEmpty(java.lang.Object[] array)
array
- Array
java.lang.IllegalArgumentException
- If array is null or emptypublic static final void isNotEmpty(java.lang.Object[] array, java.lang.String message)
array
- Arraymessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If array is null or emptypublic static final void isNotEmpty(java.lang.String string)
string
- String
java.lang.IllegalArgumentException
- If string is null or emptypublic static final void isNotEmpty(java.lang.String string, java.lang.String message)
string
- Stringmessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If string is null or emptypublic static void isNotSame(java.lang.Object firstObject, java.lang.String firstName, java.lang.Object secondObject, java.lang.String secondName)
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 and firstObject
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 and secondObject
is not null, secondObject.toString()
will
be used.
java.lang.IllegalArgumentException
- If the specified objects are the same.public static final void contains(java.util.Collection collection, java.lang.Object value)
collection
- Collection to checkvalue
- Value to check for, may be null
java.lang.IllegalArgumentException
- If collection is null or doesn't contain valuepublic static final void contains(java.util.Collection collection, java.lang.Object value, java.lang.String message)
collection
- Collection to checkvalue
- Value to check for, may be nullmessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If collection is null or doesn't contain valuepublic static final void containsKey(java.util.Map map, java.lang.Object key)
map
- Map to checkkey
- Key to check for, may be null
java.lang.IllegalArgumentException
- If map is null or doesn't contain keypublic static final void containsKey(java.util.Map map, java.lang.Object key, java.lang.String message)
map
- Map to checkkey
- Key to check for, may be nullmessage
- Exception message if check fails
java.lang.IllegalArgumentException
- If map is null or doesn't contain key
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |