|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.hazelcast.util.ValidationUtil
public final class ValidationUtil
A utility class for validating arguments and state.
| Method Summary | ||
|---|---|---|
static void |
checkFalse(boolean expression,
String message)
Tests whether the supplied expression is false. |
|
static
|
checkHasNext(Iterator<T> iterator,
String message)
Check if iterator has next element. |
|
static
|
checkInstanceOf(Class type,
E object,
String argumentName)
Tests whether the supplied object is an instance of the supplied class type. |
|
static
|
checkNotInstanceOf(Class type,
E object,
String argumentName)
Tests the supplied object to see if it is not a type of the supplied class. |
|
static
|
checkNotNull(T argument,
String message)
Tests if an argument is not null. |
|
static void |
checkState(boolean condition,
String message)
Check the state of a condition |
|
static String |
hasText(String argument,
String argName)
Tests if a string contains text. |
|
static void |
isNotNegative(long value,
String argumentName)
Tests if a long value is not negative. |
|
static
|
isNotNull(E argument,
String argName)
Tests if a string is not null. |
|
static void |
shouldBePositive(long value,
String argumentName)
Tests if a long value is positive. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <T> T checkNotNull(T argument,
String message)
argument - the argument tested to see if it is not null.message - message thrown if argument is null.
NullPointerException - if argument is null
public static String hasText(String argument,
String argName)
argument - the string tested to see if it contains text.argName - the string name (used in message if an error is thrown).
IllegalArgumentException - if the string is empty
public static <E> E isNotNull(E argument,
String argName)
argument - the string tested to see if it is not null.argName - the string name (used in message if an error is thrown).
IllegalArgumentException - if the string is null.
public static void isNotNegative(long value,
String argumentName)
value - the long value tested to see if it is not negative.argumentName - the value name (used in message if an error is thrown).
IllegalArgumentException - if the value is negative.
public static void shouldBePositive(long value,
String argumentName)
value - the long value tested to see if it is positive.argumentName - the value name (used in message if an error is thrown).
IllegalArgumentException - if the value is not positive.
public static <E> E checkInstanceOf(Class type,
E object,
String argumentName)
type - the expected type.object - the object tested against the expected type.argumentName - the argument name of the object.
IllegalArgumentException - if the object is not an instance of the expected type.
public static <E> E checkNotInstanceOf(Class type,
E object,
String argumentName)
type - the type that is not of the supplied class.object - the object tested against the type.argumentName - the argument name of the object.
IllegalArgumentException - if the object is an instance of the type that is not of the expected class.
public static void checkFalse(boolean expression,
String message)
false.
expression - the expression tested to see if it is false.message - exception message in case the supplied expression is not false.
IllegalArgumentException - if the supplied expression is true.
public static <T> Iterator<T> checkHasNext(Iterator<T> iterator,
String message)
throws NoSuchElementException
iterator - message -
NoSuchElementException - if iterator.hasNext returns false
public static void checkState(boolean condition,
String message)
throws IllegalStateException
condition - message -
IllegalStateException - if condition if false
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||