public final class AssertUtils extends Object
IllegalArgumentException if the
argument doesn't fulfil constraints.| Modifier and Type | Method and Description |
|---|---|
static boolean |
areEqual(double v1,
double v2)
The method returns true if both values area equal.
|
static void |
assertType(Object obj,
Class<?> type)
Asserts if the specified object is an instance of the specified type.
|
static void |
belongsToEnum(String name,
int[] allowedElements,
int value) |
static void |
checkArrayDimension(String name,
boolean[] array,
int defaultLength) |
static void |
checkArrayDimension(String name,
byte[] array,
int defaultLength) |
static void |
checkArrayDimension(String name,
double[] array,
int defaultLength) |
static void |
checkArrayDimension(String name,
float[] array,
int defaultLength) |
static void |
checkArrayDimension(String name,
int[] array,
int defaultLength) |
static <T> void |
equalArrays(T[] array1,
T[] array2)
Asserts that the specified arrays have the same length.
|
static void |
equalDoubleArrays(double[] array1,
double[] array2)
Asserts that the specified arrays have the same length.
|
static void |
equalDoubleArrays(double[] array1,
double[] array2,
int nMinSize)
Asserts that the specified arrays have the same length or are at least min size.
|
static void |
equalFloatArrays(float[] array1,
float[] array2)
Asserts that the specified arrays have the same length.
|
static void |
equalFloatArrays(float[] array1,
float[] array2,
int nMinSize)
Asserts that the specified arrays have the same length or are at least min size.
|
static void |
gtEqThanZero(String name,
double value)
Checks if the int value is >= 0
|
static void |
gtEqThanZero(String name,
int value)
Checks if the int value is >= 0
|
static <T extends Number> |
gtEqThanZero(String name,
T value)
Checks if the value is >= 0
|
static void |
gtOrEqual(String name,
double ref,
double len)
Checks if the variable is less or equal than the reference
|
static void |
gtOrEqual(String name,
float ref,
float len)
Checks if the variable is less or equal than the reference
|
static void |
gtOrEqual(String name,
int ref,
int len)
Checks if the variable is greater or equal than the reference
|
static void |
gtOrEqual(String name,
long ref,
long len)
Checks if the variable is less or equal than the reference
|
static void |
gtThanZero(String name,
int value)
Checks if the int value is >= 0
|
static <T extends Number> |
gtThanZero(String name,
T value)
Checks if the value is >= 0
|
static void |
indexInBounds(int index,
int bounds)
Checks if the index is >= 0 and < bounds
|
static void |
indexInBounds(int index,
int bounds,
String message)
Checks if the index is >= 0 and < bounds
|
static void |
indexOrder(int index1,
int index2,
String msg)
Checks if the index1 <= index2
|
static void |
indexOrder(int index1,
String name1,
int index2,
String name2)
Checks if the index1 <= index2
|
static void |
nonEmptyArray(String name,
boolean[] array) |
static void |
nonEmptyArray(String name,
byte[] array) |
static void |
nonEmptyArray(String name,
double[] array) |
static void |
nonEmptyArray(String name,
float[] array) |
static void |
nonEmptyArray(String name,
int[] array) |
static void |
nonEmptyArray(String name,
Object[] array) |
static <T> void |
notNull(String name,
T obj)
Checks if the object is not null.
|
public static boolean areEqual(double v1,
double v2)
false.v1 - to be checkedv2 - to be checkedtrue if v1 and v2 are Double.NaN or v1 == v2.public static void assertType(Object obj, Class<?> type)
obj - to be checkedtype - required class typeIllegalArgumentException - in case of problemspublic static void belongsToEnum(String name, int[] allowedElements, int value)
public static void checkArrayDimension(String name, boolean[] array, int defaultLength)
public static void checkArrayDimension(String name, byte[] array, int defaultLength)
public static void checkArrayDimension(String name, double[] array, int defaultLength)
public static void checkArrayDimension(String name, float[] array, int defaultLength)
public static void checkArrayDimension(String name, int[] array, int defaultLength)
public static <T> void equalArrays(T[] array1,
T[] array2)
T - generics object to be checkedarray1 - to be checkedarray2 - to be checkedpublic static void equalDoubleArrays(double[] array1,
double[] array2)
array1 - to be checkedarray2 - to be checkedpublic static void equalDoubleArrays(double[] array1,
double[] array2,
int nMinSize)
array1 - to be checkedarray2 - to be checkednMinSize - minimum required sizepublic static void equalFloatArrays(float[] array1,
float[] array2)
array1 - to be checkedarray2 - to be checkedpublic static void equalFloatArrays(float[] array1,
float[] array2,
int nMinSize)
array1 - to be checkedarray2 - to be checkednMinSize - minimum required sizepublic static void gtEqThanZero(String name, double value)
name - name to be included in the exception messagevalue - to be checkedpublic static void gtEqThanZero(String name, int value)
name - name to be included in the exception messagevalue - to be checkedpublic static <T extends Number> void gtEqThanZero(String name, T value)
T - generics object to be checkedname - name to be included in the exception messagevalue - to be checkedpublic static void gtThanZero(String name, int value)
name - name to be included in the exception messagevalue - to be checkedpublic static <T extends Number> void gtThanZero(String name, T value)
T - generics object to be checkedname - name to be included in the exception messagevalue - to be checkedpublic static void indexInBounds(int index,
int bounds)
index - index to be checkedbounds - maximum boundpublic static void indexInBounds(int index,
int bounds,
String message)
index - index to be checkedbounds - maximum boundmessage - exception messagepublic static void indexOrder(int index1,
int index2,
String msg)
index1 - index1 to be checkedindex2 - index1 to be checkedmsg - exception messagepublic static void indexOrder(int index1,
String name1,
int index2,
String name2)
index1 - index1 to be checkedname1 - name of index1index2 - index1 to be checkedname2 - name of index2public static void gtOrEqual(String name, double ref, double len)
name - name to be included in exception message.ref - referencelen - object to be checkedpublic static void gtOrEqual(String name, float ref, float len)
name - name to be included in exception message.ref - referencelen - object to be checkedpublic static void gtOrEqual(String name, int ref, int len)
name - name to be included in exception message.ref - referencelen - object to be checkedpublic static void gtOrEqual(String name, long ref, long len)
name - name to be included in exception message.ref - referencelen - object to be checkedpublic static void nonEmptyArray(String name, boolean[] array)
public static void nonEmptyArray(String name, byte[] array)
public static void nonEmptyArray(String name, double[] array)
public static void nonEmptyArray(String name, float[] array)
public static void nonEmptyArray(String name, int[] array)
public static <T> void notNull(String name, T obj)
T - generics object to be checkedname - name to be included in exception message.obj - object to be checkedCopyright © 2020 GSI Helmholtzzentrum für Schwerionenforschung GmbH. All rights reserved.