public class Validate extends Object
Constructor and Description |
---|
Validate() |
Modifier and Type | Method and Description |
---|---|
static void |
isTrue(boolean expression,
String message)
Validate that the argument condition is
true ; otherwise throwing an exception with
the specified message. |
static void |
notEmpty(Collection collection,
String message)
Validate 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)
Validate 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)
Validate 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)
Validate 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 emptyCopyright © 2015–2016. All rights reserved.