public final class Validator
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
isNull(java.lang.Object object,
java.lang.String message)
Validates that the specified argument is
null ; otherwise throwing an exception with the specified
message. |
static void |
isTrue(boolean expression,
java.lang.String message)
Validates that the argument condition is
true ; otherwise throwing an exception with the specified
message. |
static void |
notEmpty(java.util.Collection collection,
java.lang.String message)
Validates that the specified argument collection is neither
null nor a size of zero (no elements);
otherwise throwing an exception with the specified message. |
static void |
notEmpty(java.lang.Object[] array,
java.lang.String message)
Validates that the specified argument array is neither
null nor a length of zero (no elements);
otherwise throwing an exception with the specified message. |
static void |
notEmpty(java.lang.String string,
java.lang.String message)
Validator that the specified argument string is neither
null nor a length of zero (no characters);
otherwise throwing an exception with the specified message. |
static void |
notNull(java.lang.Object object,
java.lang.String message)
Validates that the specified argument is not
null ; otherwise throwing an exception with the specified
message. |
public static void isTrue(boolean expression, java.lang.String message)
true
; otherwise throwing an exception with the specified
message. This method is useful when validating according to an arbitrary boolean expression, such as validating a
primitive number or using your own custom validation expression.expression
- the boolean expression to checkmessage
- the exception message if invalidjava.lang.IllegalArgumentException
- if expression is false
public static void notEmpty(java.util.Collection collection, java.lang.String message)
null
nor a size of zero (no elements);
otherwise throwing an exception with the specified message.collection
- the collection to checkmessage
- the exception message if invalidjava.lang.IllegalArgumentException
- if the collection is emptypublic static void notEmpty(java.lang.Object[] array, java.lang.String message)
null
nor a length of zero (no elements);
otherwise throwing an exception with the specified message.array
- the array to checkmessage
- the exception message if invalidjava.lang.IllegalArgumentException
- if the array is emptypublic static void notEmpty(java.lang.String string, java.lang.String message)
null
nor a length of zero (no characters);
otherwise throwing an exception with the specified message.string
- the string to checkmessage
- the exception message if invalidjava.lang.IllegalArgumentException
- if the string is emptypublic static void notNull(java.lang.Object object, java.lang.String message)
null
; otherwise throwing an exception with the specified
message.object
- the object to checkmessage
- the exception message if invalidpublic static void isNull(java.lang.Object object, java.lang.String message)
null
; otherwise throwing an exception with the specified
message.object
- the object to checkmessage
- the exception message if invalid