|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.kano.joscar.DefensiveTools
A set of utilities for ensuring the validity (and non-nullness)
of arguments passed into methods or constructors.
| Method Summary | |
static void |
checkNull(java.lang.Object val,
java.lang.String name)
Ensures that the given value is not null. |
static void |
checkNullElements(java.lang.Object[] array,
java.lang.String arrayName)
Ensures that no element of the given array is null. |
static void |
checkNullElements(java.lang.Object[] array,
java.lang.String arrayName,
int offset,
int len)
Ensures that each of the given number of elements (starting at the given index) of the given array are not null. |
static void |
checkRange(int val,
java.lang.String name,
int min)
Ensures that the given value is greater than or equal to the given minimum value. |
static void |
checkRange(int val,
java.lang.String name,
int min,
int max)
Ensures that the given value is inclusively between the given minumum and maximum values. |
static void |
checkRange(long val,
java.lang.String name,
int min)
Ensures that the given value is greater than or equal to the given minimum value. |
static void |
checkRange(long val,
java.lang.String name,
long min,
long max)
Ensures that the given value is inclusively between the given minumum and maximum values. |
static java.lang.Object[] |
getNonnullArray(java.lang.Object[] array,
java.lang.String name)
Returns a copy of the given array, ensuring that no element of the returned array is null. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static final void checkRange(int val,
java.lang.String name,
int min)
throws java.lang.IllegalArgumentException
val - the value to checkname - the name of this variable, for debugging purposesmin - the minimum value of the given value
java.lang.IllegalArgumentException - if the given value is less than the
given minimum
public static final void checkRange(int val,
java.lang.String name,
int min,
int max)
throws java.lang.IllegalArgumentException
val - the value to checkname - the name of this variable, for debugging purposesmin - the minimum value of the given valuemax - the maximum value of the given value
java.lang.IllegalArgumentException - if the given value is less than the
given minimum or greater than the given maximum
public static void checkRange(long val,
java.lang.String name,
int min)
throws java.lang.IllegalArgumentException
val - the value to checkname - the name of this variable, for debugging purposesmin - the minimum value of the given value
java.lang.IllegalArgumentException - if the given value is less than the
given minimum
public static void checkRange(long val,
java.lang.String name,
long min,
long max)
val - the value to checkname - the name of this variable, for debugging purposesmin - the minimum value of the given valuemax - the maximum value of the given value
java.lang.IllegalArgumentException - if the given value is less than the
given minimum or greater than the given maximum
public static final void checkNull(java.lang.Object val,
java.lang.String name)
throws java.lang.IllegalArgumentException
null.
val - the value to checkname - the name of this variable, for debugging purposes
java.lang.IllegalArgumentException - if the given value is null
public static void checkNullElements(java.lang.Object[] array,
java.lang.String arrayName)
throws java.lang.IllegalArgumentException
null.
array - an array of objectsarrayName - the name of this array, for debugging purposes
java.lang.IllegalArgumentException - if an element of the given array is
null
public static void checkNullElements(java.lang.Object[] array,
java.lang.String arrayName,
int offset,
int len)
throws java.lang.IllegalArgumentException
null.
array - an array of objectsarrayName - the name of this array, for debugging purposesoffset - the index in the given array at which
len elements must not be nulllen - the number of elements, starting at the given index, which
must not be null
java.lang.IllegalArgumentException - if an element of the given array is
null
public static java.lang.Object[] getNonnullArray(java.lang.Object[] array,
java.lang.String name)
throws java.lang.IllegalArgumentException
null. If any elements of the given array
are null, an IllegalArgumentException is
thrown. Note that if the given array is null,
this method will simply return null
array - the array to clone and check for null elementsname - the name of the array variable, for debugging purposes
null elements,
or null if the given array is null
java.lang.IllegalArgumentException - if any elements of the given array are
null
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||