Java Utililty Methods Assert

List of utility methods to do Assert

Description

The list of methods to do Assert are organized into topic(s).

Method

voidassertHasText(String str)
assert Has Text
if (!hasText(str))
    throw new IllegalArgumentException("no text in str");
booleanassertHexOrDecLongValue(String value)
assert Hex Or Dec Long Value
try {
    parseHexOrDecLong(value);
} catch (NumberFormatException nfe) {
    return false;
return true;
voidassertInBounds(final String param, final int value, final int min, final int max)
Asserts that the specified integer is in the valid range.
if (value < min || value > max) {
    throw new IllegalArgumentException(
            String.format("The value of the parameter %s should be between %s and %s.", param, min, max));
voidassertInBounds(int[] coordinates)
assert In Bounds
assertWithoutBounds(coordinates);
assertInBounds(coordinates[0], coordinates[1]);
voidassertIndex(final int size, final int index)
Make sure the index provided as input is inside the range of possible elements of a list.
if (index < 0 || index >= size) {
    throw new ArrayIndexOutOfBoundsException();
intassertIndex(final String s, final int index)
assert Index
if (index >= 0)
    return index;
throw new IllegalArgumentException(s);
voidassertIndex(int index, String msg)
Asserts if index is between 0 and 63.
if ((index < 0) || (index > 63))
    throw new AssertionError(msg);
StringassertInputNotEmpty(final String input, final String message)
assert Input Not Empty
if (input == null || input.isEmpty()) {
    throw new IllegalArgumentException(message);
return input;
voidassertInstance(final Object object, final Class c)
Verifies that the given object is an instance of the given class.
assertInstance(object, c, false);
voidassertInstance(Object object, Class c)
assert Instance
assertInstance(object, c, false);