public final class Validate
extends java.lang.Object
These methods are intended for checking the arguments of public/protected methods in library classes. To check return values, or the arguments of private/package methods, use assertions.
| Modifier and Type | Field and Description |
|---|---|
static java.util.logging.Logger |
logger
message logger for this class
|
static boolean |
throwNpe
If true, throw NullPointerException for null arguments.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
axisIndex(int iValue,
java.lang.String description)
Validate an axis index as a method argument.
|
static boolean |
finite(float fValue,
java.lang.String description)
Validate a finite single-precision value as a method argument.
|
static boolean |
finite(Vec3d vector,
java.lang.String description)
Validate a finite Vec3d as a method argument.
|
static boolean |
finite(Vector3f vector,
java.lang.String description)
Validate a finite Vector3f as a method argument.
|
static boolean |
fraction(double dValue,
java.lang.String description)
Validate a non-negative proper fraction as a method argument.
|
static boolean |
fraction(float fValue,
java.lang.String description)
Validate a non-negative proper fraction as a method argument.
|
static boolean |
inRange(double dValue,
java.lang.String description,
double min,
double max)
Validate a limited double-precision value as a method argument.
|
static boolean |
inRange(float fValue,
java.lang.String description,
float min,
float max)
Validate a limited single-precision value as a method argument.
|
static boolean |
inRange(int iValue,
java.lang.String description,
int min,
int max)
Validate a limited integer as a method argument.
|
static boolean |
nonEmpty(java.util.Collection collection,
java.lang.String description)
Validate a non-null, non-empty collection as a method argument.
|
static boolean |
nonEmpty(float[] array,
java.lang.String description)
Validate a non-null, non-empty float array as a method argument.
|
static boolean |
nonEmpty(java.lang.Object[] array,
java.lang.String description)
Validate a non-null, non-empty object array as a method argument.
|
static boolean |
nonEmpty(java.lang.String string,
java.lang.String description)
Validate a non-null, non-empty string as a method argument.
|
static boolean |
nonNegative(float fValue,
java.lang.String description)
Validate a non-negative single-precision value as a method argument.
|
static boolean |
nonNegative(int iValue,
java.lang.String description)
Validate a non-negative integer as a method argument.
|
static boolean |
nonNegative(Vector3f vector,
java.lang.String description)
Validate a non-negative Vector3f as a method argument.
|
static boolean |
nonNull(java.lang.Object object,
java.lang.String description)
Validate a non-null reference.
|
static boolean |
nonZero(long lValue,
java.lang.String description)
Validate a non-zero long value as a method argument.
|
static boolean |
nonZero(Quatd quaternion,
java.lang.String description)
Validate a non-zero Quatd as a method argument.
|
static boolean |
nonZero(Quaternion quaternion,
java.lang.String description)
Validate a non-zero Quaternion as a method argument.
|
static boolean |
nonZero(Vector3f vector,
java.lang.String description)
Validate a non-zero Vector3f as a method argument.
|
static boolean |
positive(float fValue,
java.lang.String description)
Validate a positive single-precision value as a method argument.
|
static boolean |
positive(int iValue,
java.lang.String description)
Validate a positive integer value as a method argument.
|
static boolean |
positive(Vector3f vector,
java.lang.String description)
Validate an all-positive Vector3f as a method argument.
|
static boolean |
require(boolean value,
java.lang.String what)
Validate an arbitrary boolean-valued expression involving method
arguments.
|
static boolean |
standardAngle(float fValue,
java.lang.String description)
Validate a standardized angle as a method argument.
|
public static final java.util.logging.Logger logger
public static boolean throwNpe
public static boolean axisIndex(int iValue,
java.lang.String description)
iValue - the value to validatedescription - a description of the argumentjava.lang.IllegalArgumentException - if the value is outside the range [0, 2]public static boolean finite(float fValue,
java.lang.String description)
fValue - the value to validatedescription - a description of the argumentjava.lang.IllegalArgumentException - if the value is NaN or infinitepublic static boolean finite(Vector3f vector, java.lang.String description)
vector - the vector to validate (unaffected)description - a description of the argumentjava.lang.IllegalArgumentException - if the vector has a NaN or infinite
componentjava.lang.NullPointerException - or IllegalArgumentException if the vector is
nullpublic static boolean finite(Vec3d vector, java.lang.String description)
vector - the vector to validate (unaffected)description - a description of the argumentjava.lang.IllegalArgumentException - if the vector has a NaN or infinite
componentjava.lang.NullPointerException - or IllegalArgumentException if the vector is
nullpublic static boolean fraction(float fValue,
java.lang.String description)
fValue - the value to validatedescription - a description of the argumentjava.lang.IllegalArgumentException - if the value is outside the range [0, 1]public static boolean fraction(double dValue,
java.lang.String description)
dValue - the value to validatedescription - a description of the argumentjava.lang.IllegalArgumentException - if the value is outside the range [0, 1]public static boolean inRange(int iValue,
java.lang.String description,
int min,
int max)
iValue - the value to validatedescription - a description of the argumentmin - the smallest valid value (≤max)max - the largest valid value (≥max)java.lang.IllegalArgumentException - if the value is outside the range [min,
max]
Compare with Objects.checkIndex() in Java 9.
public static boolean inRange(float fValue,
java.lang.String description,
float min,
float max)
fValue - the value to validatedescription - a description of the argumentmin - the smallest valid value (≤max)max - the largest valid value (≥max)java.lang.IllegalArgumentException - if the value is outside the rangepublic static boolean inRange(double dValue,
java.lang.String description,
double min,
double max)
dValue - the value to validatedescription - a description of the argumentmin - the smallest valid value (≤max)max - the largest valid value (≥max)java.lang.IllegalArgumentException - if the value is outside the rangepublic static boolean nonEmpty(java.util.Collection collection,
java.lang.String description)
collection - the collection to validate (unaffected)description - a description of the argumentjava.lang.NullPointerException - or IllegalArgumentException if the
collection is nulljava.lang.IllegalArgumentException - if the collection is emptypublic static boolean nonEmpty(float[] array,
java.lang.String description)
array - the array to validate (unaffected)description - a description of the argumentjava.lang.NullPointerException - or IllegalArgumentException if the array is
nulljava.lang.IllegalArgumentException - if the array has zero lengthpublic static boolean nonEmpty(java.lang.Object[] array,
java.lang.String description)
array - the array to validate (unaffected)description - a description of the argumentjava.lang.NullPointerException - or IllegalArgumentException if the array is
nulljava.lang.IllegalArgumentException - if the array has zero lengthpublic static boolean nonEmpty(java.lang.String string,
java.lang.String description)
string - the String to validatedescription - a description of the argumentjava.lang.NullPointerException - or IllegalArgumentException if the String is
nulljava.lang.IllegalArgumentException - if the String has zero lengthpublic static boolean nonNegative(int iValue,
java.lang.String description)
iValue - the value to validatedescription - a description of the argumentjava.lang.IllegalArgumentException - if the value is negativepublic static boolean nonNegative(float fValue,
java.lang.String description)
fValue - the value to validatedescription - a description of the argumentjava.lang.IllegalArgumentException - if the value is negative or NaNpublic static boolean nonNegative(Vector3f vector, java.lang.String description)
vector - the vector to validate (unaffected)description - a description of the argumentjava.lang.IllegalArgumentException - if the vector has a negative or NaN
componentjava.lang.NullPointerException - or IllegalArgumentException if the vector is
nullpublic static boolean nonNull(java.lang.Object object,
java.lang.String description)
While it might seem more logical to throw an IllegalArgumentException in
the case of a method argument, the javadoc for NullPointerException says,
"Applications should throw instances of this class to indicate other
illegal uses of the null object." To throw an IllegalArgumentException
instead, set throwNpe to false.
Compare with java.util.Objects.requireNonNull().
object - the reference to validatedescription - a description of the argumentjava.lang.NullPointerException - or IllegalArgumentException if the reference
is nullpublic static boolean nonZero(long lValue,
java.lang.String description)
lValue - the value to validatedescription - a description of the argumentjava.lang.IllegalArgumentException - if the value is zeropublic static boolean nonZero(Quaternion quaternion, java.lang.String description)
quaternion - the Quaternion to validate (unaffected)description - a description of the argumentjava.lang.IllegalArgumentException - if the Quaternion equals (0,0,0,0)java.lang.NullPointerException - or IllegalArgumentException if the
Quaternion is nullpublic static boolean nonZero(Quatd quaternion, java.lang.String description)
quaternion - the Quatd to validate (unaffected)description - a description of the argumentjava.lang.IllegalArgumentException - if the Quatd equals (0,0,0,0)java.lang.NullPointerException - or IllegalArgumentException if the Quatd is
nullpublic static boolean nonZero(Vector3f vector, java.lang.String description)
vector - the vector to validate (unaffected)description - a description of the argumentjava.lang.IllegalArgumentException - if the vector equals (0,0,0)java.lang.NullPointerException - or IllegalArgumentException if the vector is
nullpublic static boolean positive(int iValue,
java.lang.String description)
iValue - the value to validatedescription - a description of the argumentjava.lang.IllegalArgumentException - if the value is negative or zeropublic static boolean positive(float fValue,
java.lang.String description)
fValue - the value to validatedescription - a description of the argumentjava.lang.IllegalArgumentException - if the value is not positivepublic static boolean positive(Vector3f vector, java.lang.String description)
vector - the vector to validate (unaffected)description - a description of the argumentjava.lang.IllegalArgumentException - if any component is not positivejava.lang.NullPointerException - or IllegalArgumentException if the vector is
nullpublic static boolean require(boolean value,
java.lang.String what)
value - the value of the expression (required to be true)what - a description of the requirementjava.lang.IllegalArgumentException - if the value is falsepublic static boolean standardAngle(float fValue,
java.lang.String description)
fValue - the value to validatedescription - a description of the argumentjava.lang.IllegalArgumentException - if the value is outside the range [-PI,
PI]