com.hazelcast.util
public final class ValidationUtil extends Object
Modifier and Type | Method and Description |
---|---|
static void |
checkFalse(boolean expression,
String message)
Tests whether the supplied expression is
false . |
static <T> Iterator<T> |
checkHasNext(Iterator<T> iterator,
String message)
Check if iterator has next element.
|
static <E> E |
checkInstanceOf(Class type,
E object,
String argumentName)
Tests whether the supplied object is an instance of the supplied class type.
|
static <E> E |
checkNotInstanceOf(Class type,
E object,
String argumentName)
Tests the supplied object to see if it is not a type of the supplied class.
|
static <T> T |
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 <E> E |
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.
|
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 nullpublic 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 emptypublic 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 falsepublic static void checkState(boolean condition, String message) throws IllegalStateException
condition
- message
- IllegalStateException
- if condition if falseCopyright © 2015 Hazelcast, Inc.. All Rights Reserved.