public final class Validator extends Object
Modifier and Type | Method and Description |
---|---|
static void |
isNull(Object object,
String message)
Validates that the specified argument is
null ; otherwise throwing an exception with the specified
message. |
static void |
isTrue(boolean expression,
String message)
Validates that the argument condition is
true ; otherwise throwing an exception with the specified
message. |
static void |
notEmpty(Collection collection,
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(Object[] array,
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(String string,
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(Object object,
String message)
Validates that the specified argument is not
null ; otherwise throwing an exception with the specified
message. |
public static void isTrue(boolean expression, 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 invalidIllegalArgumentException
- if expression is false
public static void notEmpty(Collection collection, 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 invalidIllegalArgumentException
- if the collection is emptypublic static void notEmpty(Object[] array, 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 invalidIllegalArgumentException
- if the array is emptypublic static void notEmpty(String string, 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 invalidIllegalArgumentException
- if the string is emptypublic static void notNull(Object object, String message)
null
; otherwise throwing an exception with the specified
message.object
- the object to checkmessage
- the exception message if invalidCopyright © 2015–2016 IBM Watson. All rights reserved.