Constructor and Description |
---|
Validate() |
Modifier and Type | Method and Description |
---|---|
static <T> void |
exclusiveBetween(Logger logger,
Level level,
T start,
T end,
Comparable<T> value)
Validate that the specified argument object fall between the two
exclusive values specified; otherwise, throws an exception.
|
static <T> void |
exclusiveBetween(Logger logger,
Level level,
T start,
T end,
Comparable<T> value,
String message,
Object... values)
Validate that the specified argument object fall between the two
exclusive values specified; otherwise, throws an exception with the
specified message.
|
static <T> void |
exclusiveBetween(Logger logger,
T start,
T end,
Comparable<T> value)
Validate that the specified argument object fall between the two
exclusive values specified; otherwise, throws an exception.
|
static <T> void |
exclusiveBetween(Logger logger,
T start,
T end,
Comparable<T> value,
String message,
Object... values)
Validate that the specified argument object fall between the two
exclusive values specified; otherwise, throws an exception with the
specified message.
|
static <T> void |
inclusiveBetween(Logger logger,
Level level,
T start,
T end,
Comparable<T> value)
Validate that the specified argument object fall between the two
inclusive values specified; otherwise, throws an exception.
|
static <T> void |
inclusiveBetween(Logger logger,
Level level,
T start,
T end,
Comparable<T> value,
String message,
Object... values)
Validate that the specified argument object fall between the two
inclusive values specified; otherwise, throws an exception with the
specified message.
|
static <T> void |
inclusiveBetween(Logger logger,
T start,
T end,
Comparable<T> value)
Validate that the specified argument object fall between the two
inclusive values specified; otherwise, throws an exception.
|
static <T> void |
inclusiveBetween(Logger logger,
T start,
T end,
Comparable<T> value,
String message,
Object... values)
Validate that the specified argument object fall between the two
inclusive values specified; otherwise, throws an exception with the
specified message.
|
static void |
isAssignableFrom(Logger logger,
Class<?> superType,
Class<?> type)
Validates that the argument can be converted to the specified class, if not, throws an exception.
|
static void |
isAssignableFrom(Logger logger,
Class<?> superType,
Class<?> type,
String message,
Object... values)
Validates that the argument can be converted to the specified class, if not throws an exception.
|
static void |
isAssignableFrom(Logger logger,
Level level,
Class<?> superType,
Class<?> type)
Validates that the argument can be converted to the specified class, if not, throws an exception.
|
static void |
isAssignableFrom(Logger logger,
Level level,
Class<?> superType,
Class<?> type,
String message,
Object... values)
Validates that the argument can be converted to the specified class, if not throws an exception.
|
static void |
isInstanceOf(Logger logger,
Class<?> type,
Object obj)
Validates that the argument is an instance of the specified class, if not throws an exception.
|
static void |
isInstanceOf(Logger logger,
Class<?> type,
Object obj,
String message,
Object... values)
Validate that the argument is an instance of the specified class; otherwise
throwing an exception with the specified message.
|
static void |
isInstanceOf(Logger logger,
Level level,
Class<?> type,
Object obj)
Validates that the argument is an instance of the specified class, if not throws an exception.
|
static void |
isInstanceOf(Logger logger,
Level level,
Class<?> type,
Object obj,
String message,
Object... values)
Validate that the argument is an instance of the specified class; otherwise
throwing an exception with the specified message.
|
static void |
isTrue(Logger logger,
boolean expression)
Validate that the argument condition is
true ; otherwise
throwing an exception. |
static void |
isTrue(Logger logger,
boolean expression,
String message,
double value)
Validate that the argument condition is
true ; otherwise
throwing an exception with the specified message. |
static void |
isTrue(Logger logger,
boolean expression,
String message,
long value)
Validate that the argument condition is
true ; otherwise
throwing an exception with the specified message. |
static void |
isTrue(Logger logger,
boolean expression,
String message,
Object... values)
Validate that the argument condition is
true ; otherwise
throwing an exception with the specified message. |
static void |
isTrue(Logger logger,
Level level,
boolean expression)
Validate that the argument condition is
true ; otherwise
throwing an exception. |
static void |
isTrue(Logger logger,
Level level,
boolean expression,
String message,
double value)
Validate that the argument condition is
true ; otherwise
throwing an exception with the specified message. |
static void |
isTrue(Logger logger,
Level level,
boolean expression,
String message,
long value)
Validate that the argument condition is
true ; otherwise
throwing an exception with the specified message. |
static void |
isTrue(Logger logger,
Level level,
boolean expression,
String message,
Object... values)
Validate that the argument condition is
true ; otherwise
throwing an exception with the specified message. |
static void |
matchesPattern(Logger logger,
CharSequence input,
String pattern)
Validate that the specified argument character sequence matches the specified regular
expression pattern; otherwise throwing an exception.
|
static void |
matchesPattern(Logger logger,
CharSequence input,
String pattern,
String message,
Object... values)
Validate that the specified argument character sequence matches the specified regular
expression pattern; otherwise throwing an exception with the specified message.
|
static void |
matchesPattern(Logger logger,
Level level,
CharSequence input,
String pattern)
Validate that the specified argument character sequence matches the specified regular
expression pattern; otherwise throwing an exception.
|
static void |
matchesPattern(Logger logger,
Level level,
CharSequence input,
String pattern,
String message,
Object... values)
Validate that the specified argument character sequence matches the specified regular
expression pattern; otherwise throwing an exception with the specified message.
|
static <T extends Iterable<?>> |
noNullElements(Logger logger,
Level level,
T iterable)
Validate that the specified argument iterable is neither
null nor contains any elements that are null ;
otherwise throwing an exception. |
static <T> T[] |
noNullElements(Logger logger,
Level level,
T[] array)
Validate that the specified argument array is neither
null nor contains any elements that are null ;
otherwise throwing an exception. |
static <T> T[] |
noNullElements(Logger logger,
Level level,
T[] array,
String message,
Object... values)
Validate that the specified argument array is neither
null nor contains any elements that are null ;
otherwise throwing an exception with the specified message. |
static <T extends Iterable<?>> |
noNullElements(Logger logger,
Level level,
T iterable,
String message,
Object... values)
Validate that the specified argument iterable is neither
null nor contains any elements that are null ;
otherwise throwing an exception with the specified message. |
static <T extends Iterable<?>> |
noNullElements(Logger logger,
T iterable)
Validate that the specified argument iterable is neither
null nor contains any elements that are null ;
otherwise throwing an exception. |
static <T> T[] |
noNullElements(Logger logger,
T[] array)
Validate that the specified argument array is neither
null nor contains any elements that are null ;
otherwise throwing an exception. |
static <T> T[] |
noNullElements(Logger logger,
T[] array,
String message,
Object... values)
Validate that the specified argument array is neither
null nor contains any elements that are null ;
otherwise throwing an exception with the specified message. |
static <T extends Iterable<?>> |
noNullElements(Logger logger,
T iterable,
String message,
Object... values)
Validate that the specified argument iterable is neither
null nor contains any elements that are null ;
otherwise throwing an exception with the specified message. |
static <T extends CharSequence> |
notBlank(Logger logger,
Level level,
T chars)
Validate that the specified argument character sequence is
neither
null , a length of zero (no characters), empty
nor whitespace; otherwise throwing an exception. |
static <T extends CharSequence> |
notBlank(Logger logger,
Level level,
T chars,
String message,
Object... values)
Validate that the specified argument character sequence is
neither
null , a length of zero (no characters), empty
nor whitespace; otherwise throwing an exception with the specified
message. |
static <T extends CharSequence> |
notBlank(Logger logger,
T chars)
Validate that the specified argument character sequence is
neither
null , a length of zero (no characters), empty
nor whitespace; otherwise throwing an exception. |
static <T extends CharSequence> |
notBlank(Logger logger,
T chars,
String message,
Object... values)
Validate that the specified argument character sequence is
neither
null , a length of zero (no characters), empty
nor whitespace; otherwise throwing an exception with the specified
message. |
static <T extends CharSequence> |
notEmpty(Logger logger,
Level level,
T chars)
Validate that the specified argument character sequence is
neither
null nor a length of zero (no characters);
otherwise throwing an exception with the specified message. |
static <T extends Collection<?>> |
notEmpty(Logger logger,
Level level,
T collection)
Validate that the specified argument collection is neither
null
nor a size of zero (no elements); otherwise throwing an exception. |
static <T extends Map<?,?>> |
notEmpty(Logger logger,
Level level,
T map)
Validate that the specified argument map is neither
null
nor a size of zero (no elements); otherwise throwing an exception. |
static <T> T[] |
notEmpty(Logger logger,
Level level,
T[] array)
Validate that the specified argument array is neither
null
nor a length of zero (no elements); otherwise throwing an exception. |
static <T> T[] |
notEmpty(Logger logger,
Level level,
T[] array,
String message,
Object... values)
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 <T extends CharSequence> |
notEmpty(Logger logger,
Level level,
T chars,
String message,
Object... values)
Validate that the specified argument character sequence is
neither
null nor a length of zero (no characters);
otherwise throwing an exception with the specified message. |
static <T extends Collection<?>> |
notEmpty(Logger logger,
Level level,
T collection,
String message,
Object... values)
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 <T extends Map<?,?>> |
notEmpty(Logger logger,
Level level,
T map,
String message,
Object... values)
Validate that the specified argument map is neither
null
nor a size of zero (no elements); otherwise throwing an exception
with the specified message. |
static <T extends CharSequence> |
notEmpty(Logger logger,
T chars)
Validate that the specified argument character sequence is
neither
null nor a length of zero (no characters);
otherwise throwing an exception with the specified message. |
static <T extends Collection<?>> |
notEmpty(Logger logger,
T collection)
Validate that the specified argument collection is neither
null
nor a size of zero (no elements); otherwise throwing an exception. |
static <T extends Map<?,?>> |
notEmpty(Logger logger,
T map)
Validate that the specified argument map is neither
null
nor a size of zero (no elements); otherwise throwing an exception. |
static <T> T[] |
notEmpty(Logger logger,
T[] array)
Validate that the specified argument array is neither
null
nor a length of zero (no elements); otherwise throwing an exception. |
static <T> T[] |
notEmpty(Logger logger,
T[] array,
String message,
Object... values)
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 <T extends CharSequence> |
notEmpty(Logger logger,
T chars,
String message,
Object... values)
Validate that the specified argument character sequence is
neither
null nor a length of zero (no characters);
otherwise throwing an exception with the specified message. |
static <T extends Collection<?>> |
notEmpty(Logger logger,
T collection,
String message,
Object... values)
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 <T extends Map<?,?>> |
notEmpty(Logger logger,
T map,
String message,
Object... values)
Validate that the specified argument map is neither
null
nor a size of zero (no elements); otherwise throwing an exception
with the specified message. |
static <T> T |
notNull(Logger logger,
Level level,
T object)
Validate that the specified argument is not
null ;
otherwise throwing an exception. |
static <T> T |
notNull(Logger logger,
Level level,
T object,
String message,
Object... values)
Validate that the specified argument is not
null ;
otherwise throwing an exception with the specified message. |
static <T> T |
notNull(Logger logger,
T object)
Validate that the specified argument is not
null ;
otherwise throwing an exception. |
static <T> T |
notNull(Logger logger,
T object,
String message,
Object... values)
Validate that the specified argument is not
null ;
otherwise throwing an exception with the specified message. |
static <T> T[] |
validIndex(Logger logger,
Level level,
T[] array,
int index)
Validates that the index is within the bounds of the argument
array; otherwise throwing an exception.
|
static <T> T[] |
validIndex(Logger logger,
Level level,
T[] array,
int index,
String message,
Object... values)
Validates that the index is within the bounds of the argument
array; otherwise throwing an exception with the specified message.
|
static <T extends CharSequence> |
validIndex(Logger logger,
Level level,
T chars,
int index)
Validates that the index is within the bounds of the argument
character sequence; otherwise throwing an exception.
|
static <T extends Collection<?>> |
validIndex(Logger logger,
Level level,
T collection,
int index)
Validates that the index is within the bounds of the argument
collection; otherwise throwing an exception.
|
static <T extends CharSequence> |
validIndex(Logger logger,
Level level,
T chars,
int index,
String message,
Object... values)
Validates that the index is within the bounds of the argument
character sequence; otherwise throwing an exception with the
specified message.
|
static <T extends Collection<?>> |
validIndex(Logger logger,
Level level,
T collection,
int index,
String message,
Object... values)
Validates that the index is within the bounds of the argument
collection; otherwise throwing an exception with the specified message.
|
static <T> T[] |
validIndex(Logger logger,
T[] array,
int index)
Validates that the index is within the bounds of the argument
array; otherwise throwing an exception.
|
static <T> T[] |
validIndex(Logger logger,
T[] array,
int index,
String message,
Object... values)
Validates that the index is within the bounds of the argument
array; otherwise throwing an exception with the specified message.
|
static <T extends CharSequence> |
validIndex(Logger logger,
T chars,
int index)
Validates that the index is within the bounds of the argument
character sequence; otherwise throwing an exception.
|
static <T extends Collection<?>> |
validIndex(Logger logger,
T collection,
int index)
Validates that the index is within the bounds of the argument
collection; otherwise throwing an exception.
|
static <T extends CharSequence> |
validIndex(Logger logger,
T chars,
int index,
String message,
Object... values)
Validates that the index is within the bounds of the argument
character sequence; otherwise throwing an exception with the
specified message.
|
static <T extends Collection<?>> |
validIndex(Logger logger,
T collection,
int index,
String message,
Object... values)
Validates that the index is within the bounds of the argument
collection; otherwise throwing an exception with the specified message.
|
static void |
validState(Logger logger,
boolean expression)
Validate that the stateful condition is
true ; otherwise
throwing an exception. |
static void |
validState(Logger logger,
boolean expression,
String message,
Object... values)
Validate that the stateful condition is
true ; otherwise
throwing an exception with the specified message. |
static void |
validState(Logger logger,
Level level,
boolean expression)
Validate that the stateful condition is
true ; otherwise
throwing an exception. |
static void |
validState(Logger logger,
Level level,
boolean expression,
String message,
Object... values)
Validate that the stateful condition is
true ; otherwise
throwing an exception with the specified message. |
public static void isTrue(Logger logger, boolean expression, String message, long value)
Validate that the argument condition is 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.
Validate.isTrue(i > 0.0, "The value must be greater than zero: %d", i);
For performance reasons, the long value is passed as a separate parameter and appended to the exception message only in the case of an error.
logger
- the logger via which to log the exceptionexpression
- the boolean expression to checkmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalue
- the value to append to the message when invalidIllegalArgumentException
- if expression is false
isTrue(Logger, boolean)
,
isTrue(Logger, boolean, String, double)
,
isTrue(Logger, boolean, String, Object...)
public static void isTrue(Logger logger, Level level, boolean expression, String message, long value)
Validate that the argument condition is 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.
Validate.isTrue(i > 0.0, "The value must be greater than zero: %d", i);
For performance reasons, the long value is passed as a separate parameter and appended to the exception message only in the case of an error.
logger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionexpression
- the boolean expression to checkmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalue
- the value to append to the message when invalidIllegalArgumentException
- if expression is false
isTrue(Logger, boolean)
,
isTrue(Logger, boolean, String, double)
,
isTrue(Logger, boolean, String, Object...)
public static void isTrue(Logger logger, boolean expression, String message, double value)
Validate that the argument condition is 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.
Validate.isTrue(d > 0.0, "The value must be greater than zero: %s", d);
For performance reasons, the double value is passed as a separate parameter and appended to the exception message only in the case of an error.
logger
- the logger via which to log the exceptionexpression
- the boolean expression to checkmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalue
- the value to append to the message when invalidIllegalArgumentException
- if expression is false
isTrue(Logger, boolean)
,
isTrue(Logger, boolean, String, long)
,
isTrue(Logger, boolean, String, Object...)
public static void isTrue(Logger logger, Level level, boolean expression, String message, double value)
Validate that the argument condition is 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.
Validate.isTrue(d > 0.0, "The value must be greater than zero: %s", d);
For performance reasons, the double value is passed as a separate parameter and appended to the exception message only in the case of an error.
logger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionexpression
- the boolean expression to checkmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalue
- the value to append to the message when invalidIllegalArgumentException
- if expression is false
isTrue(Logger, boolean)
,
isTrue(Logger, boolean, String, long)
,
isTrue(Logger, boolean, String, Object...)
public static void isTrue(Logger logger, boolean expression, String message, Object... values)
Validate that the argument condition is 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.
Validate.isTrue(i >= min & i <= max, "The value must be between %d and %d", min, max); Validate.isTrue(myObject.isOk(), "The object is not okay");
logger
- the logger via which to log the exceptionexpression
- the boolean expression to checkmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendedIllegalArgumentException
- if expression is false
isTrue(Logger, boolean)
,
isTrue(Logger, boolean, String, long)
,
isTrue(Logger, boolean, String, double)
public static void isTrue(Logger logger, Level level, boolean expression, String message, Object... values)
Validate that the argument condition is 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.
Validate.isTrue(i >= min & i <= max, "The value must be between %d and %d", min, max); Validate.isTrue(myObject.isOk(), "The object is not okay");
logger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionexpression
- the boolean expression to checkmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendedIllegalArgumentException
- if expression is false
isTrue(Logger, boolean)
,
isTrue(Logger, boolean, String, long)
,
isTrue(Logger, boolean, String, double)
public static void isTrue(Logger logger, boolean expression)
Validate that the argument condition is true
; otherwise
throwing an exception. 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.
Validate.isTrue(i > 0); Validate.isTrue(myObject.isOk());
The message of the exception is "The validated expression is false".
logger
- the logger via which to log the exceptionexpression
- the boolean expression to checkIllegalArgumentException
- if expression is false
isTrue(Logger, boolean, String, long)
,
isTrue(Logger, boolean, String, double)
,
isTrue(Logger, boolean, String, Object...)
public static void isTrue(Logger logger, Level level, boolean expression)
Validate that the argument condition is true
; otherwise
throwing an exception. 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.
Validate.isTrue(i > 0); Validate.isTrue(myObject.isOk());
The message of the exception is "The validated expression is false".
logger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionexpression
- the boolean expression to checkIllegalArgumentException
- if expression is false
isTrue(Logger, boolean, String, long)
,
isTrue(Logger, boolean, String, double)
,
isTrue(Logger, boolean, String, Object...)
public static <T> T notNull(Logger logger, T object)
Validate that the specified argument is not null
;
otherwise throwing an exception.
Validate.notNull(myObject, "The object must not be null");
The message of the exception is "The validated object is null".
T
- the object typelogger
- the logger via which to log the exceptionobject
- the object to checknull
for method chaining)NullPointerException
- if the object is null
notNull(Logger, Object, String, Object...)
public static <T> T notNull(Logger logger, Level level, T object)
Validate that the specified argument is not null
;
otherwise throwing an exception.
Validate.notNull(myObject, "The object must not be null");
The message of the exception is "The validated object is null".
T
- the object typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionobject
- the object to checknull
for method chaining)NullPointerException
- if the object is null
notNull(Logger, Object, String, Object...)
public static <T> T notNull(Logger logger, T object, String message, Object... values)
Validate that the specified argument is not null
;
otherwise throwing an exception with the specified message.
Validate.notNull(myObject, "The object must not be null");
T
- the object typelogger
- the logger via which to log the exceptionobject
- the object to checkmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception messagenull
for method chaining)NullPointerException
- if the object is null
notNull(Logger, Object)
public static <T> T notNull(Logger logger, Level level, T object, String message, Object... values)
Validate that the specified argument is not null
;
otherwise throwing an exception with the specified message.
Validate.notNull(myObject, "The object must not be null");
T
- the object typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionobject
- the object to checkmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception messagenull
for method chaining)NullPointerException
- if the object is null
notNull(Logger, Object)
public static <T> T[] notEmpty(Logger logger, T[] array, String message, Object... values)
Validate that the specified argument array is neither null
nor a length of zero (no elements); otherwise throwing an exception
with the specified message.
Validate.notEmpty(myArray, "The array must not be empty");
T
- the array typelogger
- the logger via which to log the exceptionarray
- the array to check, validated not null by this methodmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
method for chaining)NullPointerException
- if the array is null
IllegalArgumentException
- if the array is emptynotEmpty(Logger, Object[])
public static <T> T[] notEmpty(Logger logger, Level level, T[] array, String message, Object... values)
Validate that the specified argument array is neither null
nor a length of zero (no elements); otherwise throwing an exception
with the specified message.
Validate.notEmpty(myArray, "The array must not be empty");
T
- the array typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionarray
- the array to check, validated not null by this methodmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
method for chaining)NullPointerException
- if the array is null
IllegalArgumentException
- if the array is emptynotEmpty(Logger, Object[])
public static <T> T[] notEmpty(Logger logger, T[] array)
Validate that the specified argument array is neither null
nor a length of zero (no elements); otherwise throwing an exception.
Validate.notEmpty(myArray);
The message in the exception is "The validated array is empty".
T
- the array typelogger
- the logger via which to log the exceptionarray
- the array to check, validated not null by this methodnull
method for chaining)NullPointerException
- if the array is null
IllegalArgumentException
- if the array is emptynotEmpty(Logger, Object[], String, Object...)
public static <T> T[] notEmpty(Logger logger, Level level, T[] array)
Validate that the specified argument array is neither null
nor a length of zero (no elements); otherwise throwing an exception.
Validate.notEmpty(myArray);
The message in the exception is "The validated array is empty".
T
- the array typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionarray
- the array to check, validated not null by this methodnull
method for chaining)NullPointerException
- if the array is null
IllegalArgumentException
- if the array is emptynotEmpty(Logger, Object[], String, Object...)
public static <T extends Collection<?>> T notEmpty(Logger logger, T collection, String message, Object... values)
Validate that the specified argument collection is neither null
nor a size of zero (no elements); otherwise throwing an exception
with the specified message.
Validate.notEmpty(myCollection, "The collection must not be empty");
T
- the collection typelogger
- the logger via which to log the exceptioncollection
- the collection to check, validated not null by this methodmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
method for chaining)NullPointerException
- if the collection is null
IllegalArgumentException
- if the collection is emptynotEmpty(Logger, Object[])
public static <T extends Collection<?>> T notEmpty(Logger logger, Level level, T collection, String message, Object... values)
Validate that the specified argument collection is neither null
nor a size of zero (no elements); otherwise throwing an exception
with the specified message.
Validate.notEmpty(myCollection, "The collection must not be empty");
T
- the collection typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptioncollection
- the collection to check, validated not null by this methodmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
method for chaining)NullPointerException
- if the collection is null
IllegalArgumentException
- if the collection is emptynotEmpty(Logger, Object[])
public static <T extends Collection<?>> T notEmpty(Logger logger, T collection)
Validate that the specified argument collection is neither null
nor a size of zero (no elements); otherwise throwing an exception.
Validate.notEmpty(myCollection);
The message in the exception is "The validated collection is empty".
T
- the collection typelogger
- the logger via which to log the exceptioncollection
- the collection to check, validated not null by this methodnull
method for chaining)NullPointerException
- if the collection is null
IllegalArgumentException
- if the collection is emptynotEmpty(Logger, Collection, String, Object...)
public static <T extends Collection<?>> T notEmpty(Logger logger, Level level, T collection)
Validate that the specified argument collection is neither null
nor a size of zero (no elements); otherwise throwing an exception.
Validate.notEmpty(myCollection);
The message in the exception is "The validated collection is empty".
T
- the collection typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptioncollection
- the collection to check, validated not null by this methodnull
method for chaining)NullPointerException
- if the collection is null
IllegalArgumentException
- if the collection is emptynotEmpty(Logger, Collection, String, Object...)
public static <T extends Map<?,?>> T notEmpty(Logger logger, T map, String message, Object... values)
Validate that the specified argument map is neither null
nor a size of zero (no elements); otherwise throwing an exception
with the specified message.
Validate.notEmpty(myMap, "The map must not be empty");
T
- the map typelogger
- the logger via which to log the exceptionmap
- the map to check, validated not null by this methodmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
method for chaining)NullPointerException
- if the map is null
IllegalArgumentException
- if the map is emptynotEmpty(Logger, Object[])
public static <T extends Map<?,?>> T notEmpty(Logger logger, Level level, T map, String message, Object... values)
Validate that the specified argument map is neither null
nor a size of zero (no elements); otherwise throwing an exception
with the specified message.
Validate.notEmpty(myMap, "The map must not be empty");
T
- the map typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionmap
- the map to check, validated not null by this methodmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
method for chaining)NullPointerException
- if the map is null
IllegalArgumentException
- if the map is emptynotEmpty(Logger, Object[])
public static <T extends Map<?,?>> T notEmpty(Logger logger, T map)
Validate that the specified argument map is neither null
nor a size of zero (no elements); otherwise throwing an exception.
Validate.notEmpty(myMap);
The message in the exception is "The validated map is empty".
T
- the map typelogger
- the logger via which to log the exceptionmap
- the map to check, validated not null by this methodnull
method for chaining)NullPointerException
- if the map is null
IllegalArgumentException
- if the map is emptynotEmpty(Logger, Map, String, Object...)
public static <T extends Map<?,?>> T notEmpty(Logger logger, Level level, T map)
Validate that the specified argument map is neither null
nor a size of zero (no elements); otherwise throwing an exception.
Validate.notEmpty(myMap);
The message in the exception is "The validated map is empty".
T
- the map typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionmap
- the map to check, validated not null by this methodnull
method for chaining)NullPointerException
- if the map is null
IllegalArgumentException
- if the map is emptynotEmpty(Logger, Map, String, Object...)
public static <T extends CharSequence> T notEmpty(Logger logger, T chars, String message, Object... values)
Validate that the specified argument character sequence is
neither null
nor a length of zero (no characters);
otherwise throwing an exception with the specified message.
Validate.notEmpty(myString, "The string must not be empty");
T
- the character sequence typelogger
- the logger via which to log the exceptionchars
- the character sequence to check, validated not null by this methodmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
method for chaining)NullPointerException
- if the character sequence is null
IllegalArgumentException
- if the character sequence is emptynotEmpty(Logger, CharSequence)
public static <T extends CharSequence> T notEmpty(Logger logger, Level level, T chars, String message, Object... values)
Validate that the specified argument character sequence is
neither null
nor a length of zero (no characters);
otherwise throwing an exception with the specified message.
Validate.notEmpty(myString, "The string must not be empty");
T
- the character sequence typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionchars
- the character sequence to check, validated not null by this methodmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
method for chaining)NullPointerException
- if the character sequence is null
IllegalArgumentException
- if the character sequence is emptynotEmpty(Logger, CharSequence)
public static <T extends CharSequence> T notEmpty(Logger logger, T chars)
Validate that the specified argument character sequence is
neither null
nor a length of zero (no characters);
otherwise throwing an exception with the specified message.
Validate.notEmpty(myString);
The message in the exception is "The validated character sequence is empty".
T
- the character sequence typelogger
- the logger via which to log the exceptionchars
- the character sequence to check, validated not null by this methodnull
method for chaining)NullPointerException
- if the character sequence is null
IllegalArgumentException
- if the character sequence is emptynotEmpty(Logger, CharSequence, String, Object...)
public static <T extends CharSequence> T notEmpty(Logger logger, Level level, T chars)
Validate that the specified argument character sequence is
neither null
nor a length of zero (no characters);
otherwise throwing an exception with the specified message.
Validate.notEmpty(myString);
The message in the exception is "The validated character sequence is empty".
T
- the character sequence typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionchars
- the character sequence to check, validated not null by this methodnull
method for chaining)NullPointerException
- if the character sequence is null
IllegalArgumentException
- if the character sequence is emptynotEmpty(Logger, CharSequence, String, Object...)
public static <T extends CharSequence> T notBlank(Logger logger, T chars, String message, Object... values)
Validate that the specified argument character sequence is
neither null
, a length of zero (no characters), empty
nor whitespace; otherwise throwing an exception with the specified
message.
Validate.notBlank(myString, "The string must not be blank");
T
- the character sequence typelogger
- the logger via which to log the exceptionchars
- the character sequence to check, validated not null by this methodmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
method for chaining)NullPointerException
- if the character sequence is null
IllegalArgumentException
- if the character sequence is blanknotBlank(Logger, CharSequence)
public static <T extends CharSequence> T notBlank(Logger logger, Level level, T chars, String message, Object... values)
Validate that the specified argument character sequence is
neither null
, a length of zero (no characters), empty
nor whitespace; otherwise throwing an exception with the specified
message.
Validate.notBlank(myString, "The string must not be blank");
T
- the character sequence typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionchars
- the character sequence to check, validated not null by this methodmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
method for chaining)NullPointerException
- if the character sequence is null
IllegalArgumentException
- if the character sequence is blanknotBlank(Logger, CharSequence)
public static <T extends CharSequence> T notBlank(Logger logger, T chars)
Validate that the specified argument character sequence is
neither null
, a length of zero (no characters), empty
nor whitespace; otherwise throwing an exception.
Validate.notBlank(myString);
The message in the exception is "The validated character sequence is blank".
T
- the character sequence typelogger
- the logger via which to log the exceptionchars
- the character sequence to check, validated not null by this methodnull
method for chaining)NullPointerException
- if the character sequence is null
IllegalArgumentException
- if the character sequence is blanknotBlank(Logger, CharSequence, String, Object...)
public static <T extends CharSequence> T notBlank(Logger logger, Level level, T chars)
Validate that the specified argument character sequence is
neither null
, a length of zero (no characters), empty
nor whitespace; otherwise throwing an exception.
Validate.notBlank(myString);
The message in the exception is "The validated character sequence is blank".
T
- the character sequence typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionchars
- the character sequence to check, validated not null by this methodnull
method for chaining)NullPointerException
- if the character sequence is null
IllegalArgumentException
- if the character sequence is blanknotBlank(Logger, CharSequence, String, Object...)
public static <T> T[] noNullElements(Logger logger, T[] array, String message, Object... values)
Validate that the specified argument array is neither
null
nor contains any elements that are null
;
otherwise throwing an exception with the specified message.
Validate.noNullElements(myArray, "The array contain null at position %d");
If the array is null
, then the message in the exception
is "The validated object is null".
If the array has a null
element, then the iteration
index of the invalid element is appended to the values
argument.
T
- the array typelogger
- the logger via which to log the exceptionarray
- the array to check, validated not null by this methodmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
method for chaining)NullPointerException
- if the array is null
IllegalArgumentException
- if an element is null
noNullElements(Logger, Object[])
public static <T> T[] noNullElements(Logger logger, Level level, T[] array, String message, Object... values)
Validate that the specified argument array is neither
null
nor contains any elements that are null
;
otherwise throwing an exception with the specified message.
Validate.noNullElements(myArray, "The array contain null at position %d");
If the array is null
, then the message in the exception
is "The validated object is null".
If the array has a null
element, then the iteration
index of the invalid element is appended to the values
argument.
T
- the array typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionarray
- the array to check, validated not null by this methodmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
method for chaining)NullPointerException
- if the array is null
IllegalArgumentException
- if an element is null
noNullElements(Logger, Object[])
public static <T> T[] noNullElements(Logger logger, T[] array)
Validate that the specified argument array is neither
null
nor contains any elements that are null
;
otherwise throwing an exception.
Validate.noNullElements(myArray);
If the array is null
, then the message in the exception
is "The validated object is null".
If the array has a null
element, then the message in the
exception is "The validated array contains null element at index:
" followed by the index.
T
- the array typelogger
- the logger via which to log the exceptionarray
- the array to check, validated not null by this methodnull
method for chaining)NullPointerException
- if the array is null
IllegalArgumentException
- if an element is null
noNullElements(Logger, Object[], String, Object...)
public static <T> T[] noNullElements(Logger logger, Level level, T[] array)
Validate that the specified argument array is neither
null
nor contains any elements that are null
;
otherwise throwing an exception.
Validate.noNullElements(myArray);
If the array is null
, then the message in the exception
is "The validated object is null".
If the array has a null
element, then the message in the
exception is "The validated array contains null element at index:
" followed by the index.
T
- the array typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionarray
- the array to check, validated not null by this methodnull
method for chaining)NullPointerException
- if the array is null
IllegalArgumentException
- if an element is null
noNullElements(Logger, Object[], String, Object...)
public static <T extends Iterable<?>> T noNullElements(Logger logger, T iterable, String message, Object... values)
Validate that the specified argument iterable is neither
null
nor contains any elements that are null
;
otherwise throwing an exception with the specified message.
Validate.noNullElements(myCollection, "The collection contains null at position %d");
If the iterable is null
, then the message in the exception
is "The validated object is null".
If the iterable has a null
element, then the iteration
index of the invalid element is appended to the values
argument.
T
- the iterable typelogger
- the logger via which to log the exceptioniterable
- the iterable to check, validated not null by this methodmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
method for chaining)NullPointerException
- if the array is null
IllegalArgumentException
- if an element is null
noNullElements(Logger, Iterable)
public static <T extends Iterable<?>> T noNullElements(Logger logger, Level level, T iterable, String message, Object... values)
Validate that the specified argument iterable is neither
null
nor contains any elements that are null
;
otherwise throwing an exception with the specified message.
Validate.noNullElements(myCollection, "The collection contains null at position %d");
If the iterable is null
, then the message in the exception
is "The validated object is null".
If the iterable has a null
element, then the iteration
index of the invalid element is appended to the values
argument.
T
- the iterable typelevel
- the level at which to log the exceptionlogger
- the logger via which to log the exceptioniterable
- the iterable to check, validated not null by this methodmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
method for chaining)NullPointerException
- if the array is null
IllegalArgumentException
- if an element is null
noNullElements(Logger, Iterable)
public static <T extends Iterable<?>> T noNullElements(Logger logger, T iterable)
Validate that the specified argument iterable is neither
null
nor contains any elements that are null
;
otherwise throwing an exception.
Validate.noNullElements(myCollection);
If the iterable is null
, then the message in the exception
is "The validated object is null".
If the array has a null
element, then the message in the
exception is "The validated iterable contains null element at index:
" followed by the index.
T
- the iterable typelogger
- the logger via which to log the exceptioniterable
- the iterable to check, validated not null by this methodnull
method for chaining)NullPointerException
- if the array is null
IllegalArgumentException
- if an element is null
noNullElements(Logger, Iterable, String, Object...)
public static <T extends Iterable<?>> T noNullElements(Logger logger, Level level, T iterable)
Validate that the specified argument iterable is neither
null
nor contains any elements that are null
;
otherwise throwing an exception.
Validate.noNullElements(myCollection);
If the iterable is null
, then the message in the exception
is "The validated object is null".
If the array has a null
element, then the message in the
exception is "The validated iterable contains null element at index:
" followed by the index.
T
- the iterable typelevel
- the level at which to log the exceptionlogger
- the logger via which to log the exceptioniterable
- the iterable to check, validated not null by this methodnull
method for chaining)NullPointerException
- if the array is null
IllegalArgumentException
- if an element is null
noNullElements(Logger, Iterable, String, Object...)
public static <T> T[] validIndex(Logger logger, T[] array, int index, String message, Object... values)
Validates that the index is within the bounds of the argument array; otherwise throwing an exception with the specified message.
Validate.validIndex(myArray, 2, "The array index is invalid: ");
If the array is null
, then the message of the exception
is "The validated object is null".
T
- the array typelogger
- the logger via which to log the exceptionarray
- the array to check, validated not null by this methodindex
- the index to checkmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
for method chaining)NullPointerException
- if the array is null
IndexOutOfBoundsException
- if the index is invalidvalidIndex(Logger, Object[], int)
public static <T> T[] validIndex(Logger logger, Level level, T[] array, int index, String message, Object... values)
Validates that the index is within the bounds of the argument array; otherwise throwing an exception with the specified message.
Validate.validIndex(myArray, 2, "The array index is invalid: ");
If the array is null
, then the message of the exception
is "The validated object is null".
T
- the array typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionarray
- the array to check, validated not null by this methodindex
- the index to checkmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
for method chaining)NullPointerException
- if the array is null
IndexOutOfBoundsException
- if the index is invalidvalidIndex(Logger, Object[], int)
public static <T> T[] validIndex(Logger logger, T[] array, int index)
Validates that the index is within the bounds of the argument array; otherwise throwing an exception.
Validate.validIndex(myArray, 2);
If the array is null
, then the message of the exception
is "The validated object is null".
If the index is invalid, then the message of the exception is "The validated array index is invalid: " followed by the index.
T
- the array typelogger
- the logger via which to log the exceptionarray
- the array to check, validated not null by this methodindex
- the index to checknull
for method chaining)NullPointerException
- if the array is null
IndexOutOfBoundsException
- if the index is invalidvalidIndex(Logger, Object[], int, String, Object...)
public static <T> T[] validIndex(Logger logger, Level level, T[] array, int index)
Validates that the index is within the bounds of the argument array; otherwise throwing an exception.
Validate.validIndex(myArray, 2);
If the array is null
, then the message of the exception
is "The validated object is null".
If the index is invalid, then the message of the exception is "The validated array index is invalid: " followed by the index.
T
- the array typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionarray
- the array to check, validated not null by this methodindex
- the index to checknull
for method chaining)NullPointerException
- if the array is null
IndexOutOfBoundsException
- if the index is invalidvalidIndex(Logger, Object[], int, String, Object...)
public static <T extends Collection<?>> T validIndex(Logger logger, T collection, int index, String message, Object... values)
Validates that the index is within the bounds of the argument collection; otherwise throwing an exception with the specified message.
Validate.validIndex(myCollection, 2, "The collection index is invalid: ");
If the collection is null
, then the message of the
exception is "The validated object is null".
T
- the collection typelogger
- the logger via which to log the exceptioncollection
- the collection to check, validated not null by this methodindex
- the index to checkmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
for chaining)NullPointerException
- if the collection is null
IndexOutOfBoundsException
- if the index is invalidvalidIndex(Logger, Collection, int)
public static <T extends Collection<?>> T validIndex(Logger logger, Level level, T collection, int index, String message, Object... values)
Validates that the index is within the bounds of the argument collection; otherwise throwing an exception with the specified message.
Validate.validIndex(myCollection, 2, "The collection index is invalid: ");
If the collection is null
, then the message of the
exception is "The validated object is null".
T
- the collection typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptioncollection
- the collection to check, validated not null by this methodindex
- the index to checkmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
for chaining)NullPointerException
- if the collection is null
IndexOutOfBoundsException
- if the index is invalidvalidIndex(Logger, Collection, int)
public static <T extends Collection<?>> T validIndex(Logger logger, T collection, int index)
Validates that the index is within the bounds of the argument collection; otherwise throwing an exception.
Validate.validIndex(myCollection, 2);
If the index is invalid, then the message of the exception is "The validated collection index is invalid: " followed by the index.
T
- the collection typelogger
- the logger via which to log the exceptioncollection
- the collection to check, validated not null by this methodindex
- the index to checknull
for method chaining)NullPointerException
- if the collection is null
IndexOutOfBoundsException
- if the index is invalidvalidIndex(Logger, Collection, int, String, Object...)
public static <T extends Collection<?>> T validIndex(Logger logger, Level level, T collection, int index)
Validates that the index is within the bounds of the argument collection; otherwise throwing an exception.
Validate.validIndex(myCollection, 2);
If the index is invalid, then the message of the exception is "The validated collection index is invalid: " followed by the index.
T
- the collection typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptioncollection
- the collection to check, validated not null by this methodindex
- the index to checknull
for method chaining)NullPointerException
- if the collection is null
IndexOutOfBoundsException
- if the index is invalidvalidIndex(Logger, Collection, int, String, Object...)
public static <T extends CharSequence> T validIndex(Logger logger, T chars, int index, String message, Object... values)
Validates that the index is within the bounds of the argument character sequence; otherwise throwing an exception with the specified message.
Validate.validIndex(myStr, 2, "The string index is invalid: ");
If the character sequence is null
, then the message
of the exception is "The validated object is null".
T
- the character sequence typelogger
- the logger via which to log the exceptionchars
- the character sequence to check, validated not null by this methodindex
- the index to checkmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
for method chaining)NullPointerException
- if the character sequence is null
IndexOutOfBoundsException
- if the index is invalidvalidIndex(Logger, CharSequence, int)
public static <T extends CharSequence> T validIndex(Logger logger, Level level, T chars, int index, String message, Object... values)
Validates that the index is within the bounds of the argument character sequence; otherwise throwing an exception with the specified message.
Validate.validIndex(myStr, 2, "The string index is invalid: ");
If the character sequence is null
, then the message
of the exception is "The validated object is null".
T
- the character sequence typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionchars
- the character sequence to check, validated not null by this methodindex
- the index to checkmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendednull
for method chaining)NullPointerException
- if the character sequence is null
IndexOutOfBoundsException
- if the index is invalidvalidIndex(Logger, CharSequence, int)
public static <T extends CharSequence> T validIndex(Logger logger, T chars, int index)
Validates that the index is within the bounds of the argument character sequence; otherwise throwing an exception.
Validate.validIndex(myStr, 2);
If the character sequence is null
, then the message
of the exception is "The validated object is
null".
If the index is invalid, then the message of the exception is "The validated character sequence index is invalid: " followed by the index.
T
- the character sequence typelogger
- the logger via which to log the exceptionchars
- the character sequence to check, validated not null by this methodindex
- the index to checknull
for method chaining)NullPointerException
- if the character sequence is null
IndexOutOfBoundsException
- if the index is invalidvalidIndex(Logger, CharSequence, int, String, Object...)
public static <T extends CharSequence> T validIndex(Logger logger, Level level, T chars, int index)
Validates that the index is within the bounds of the argument character sequence; otherwise throwing an exception.
Validate.validIndex(myStr, 2);
If the character sequence is null
, then the message
of the exception is "The validated object is
null".
If the index is invalid, then the message of the exception is "The validated character sequence index is invalid: " followed by the index.
T
- the character sequence typelogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionchars
- the character sequence to check, validated not null by this methodindex
- the index to checknull
for method chaining)NullPointerException
- if the character sequence is null
IndexOutOfBoundsException
- if the index is invalidvalidIndex(Logger, CharSequence, int, String, Object...)
public static void validState(Logger logger, boolean expression)
Validate that the stateful condition is true
; otherwise
throwing an exception. 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.
Validate.validState(field > 0); Validate.validState(this.isOk());
The message of the exception is "The validated state is false".
logger
- the logger via which to log the exceptionexpression
- the boolean expression to checkIllegalStateException
- if expression is false
validState(Logger, boolean, String, Object...)
public static void validState(Logger logger, Level level, boolean expression)
Validate that the stateful condition is true
; otherwise
throwing an exception. 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.
Validate.validState(field > 0); Validate.validState(this.isOk());
The message of the exception is "The validated state is false".
logger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionexpression
- the boolean expression to checkIllegalStateException
- if expression is false
validState(Logger, boolean, String, Object...)
public static void validState(Logger logger, boolean expression, String message, Object... values)
Validate that the stateful condition is 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.
Validate.validState(this.isOk(), "The state is not OK: %s", myObject);
logger
- the logger via which to log the exceptionexpression
- the boolean expression to checkmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendedIllegalStateException
- if expression is false
validState(Logger, boolean)
public static void validState(Logger logger, Level level, boolean expression, String message, Object... values)
Validate that the stateful condition is 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.
Validate.validState(this.isOk(), "The state is not OK: %s", myObject);
logger
- the logger via which to log the exceptionexpression
- the boolean expression to checklevel
- the level at which to log the exceptionmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendedIllegalStateException
- if expression is false
validState(Logger, boolean)
public static void matchesPattern(Logger logger, CharSequence input, String pattern)
Validate that the specified argument character sequence matches the specified regular expression pattern; otherwise throwing an exception.
Validate.matchesPattern("hi", "[a-z]*");
The syntax of the pattern is the one used in the Pattern
class.
logger
- the logger via which to log the exceptioninput
- the character sequence to validate, not nullpattern
- the regular expression pattern, not nullIllegalArgumentException
- if the character sequence does not match the patternmatchesPattern(Logger, CharSequence, String, String, Object...)
public static void matchesPattern(Logger logger, Level level, CharSequence input, String pattern)
Validate that the specified argument character sequence matches the specified regular expression pattern; otherwise throwing an exception.
Validate.matchesPattern("hi", "[a-z]*");
The syntax of the pattern is the one used in the Pattern
class.
logger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptioninput
- the character sequence to validate, not nullpattern
- the regular expression pattern, not nullIllegalArgumentException
- if the character sequence does not match the patternmatchesPattern(Logger, CharSequence, String, String, Object...)
public static void matchesPattern(Logger logger, CharSequence input, String pattern, String message, Object... values)
Validate that the specified argument character sequence matches the specified regular expression pattern; otherwise throwing an exception with the specified message.
Validate.matchesPattern("hi", "[a-z]*", "%s does not match %s", "hi" "[a-z]*");
The syntax of the pattern is the one used in the Pattern
class.
logger
- the logger via which to log the exceptioninput
- the character sequence to validate, not nullpattern
- the regular expression pattern, not nullmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendedIllegalArgumentException
- if the character sequence does not match the patternmatchesPattern(Logger, CharSequence, String)
public static void matchesPattern(Logger logger, Level level, CharSequence input, String pattern, String message, Object... values)
Validate that the specified argument character sequence matches the specified regular expression pattern; otherwise throwing an exception with the specified message.
Validate.matchesPattern("hi", "[a-z]*", "%s does not match %s", "hi" "[a-z]*");
The syntax of the pattern is the one used in the Pattern
class.
logger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptioninput
- the character sequence to validate, not nullpattern
- the regular expression pattern, not nullmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendedIllegalArgumentException
- if the character sequence does not match the patternmatchesPattern(Logger, CharSequence, String)
public static <T> void inclusiveBetween(Logger logger, T start, T end, Comparable<T> value)
Validate that the specified argument object fall between the two inclusive values specified; otherwise, throws an exception.
Validate.inclusiveBetween(0, 2, 1);
T
- the type of the argument objectlogger
- the logger via which to log the exceptionstart
- the inclusive start value, not nullend
- the inclusive end value, not nullvalue
- the object to validate, not nullIllegalArgumentException
- if the value falls out of the boundariesinclusiveBetween(Logger, Object, Object, Comparable, String, Object...)
public static <T> void inclusiveBetween(Logger logger, Level level, T start, T end, Comparable<T> value)
Validate that the specified argument object fall between the two inclusive values specified; otherwise, throws an exception.
Validate.inclusiveBetween(0, 2, 1);
T
- the type of the argument objectlogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionstart
- the inclusive start value, not nullend
- the inclusive end value, not nullvalue
- the object to validate, not nullIllegalArgumentException
- if the value falls out of the boundariesinclusiveBetween(Logger, Object, Object, Comparable, String, Object...)
public static <T> void inclusiveBetween(Logger logger, T start, T end, Comparable<T> value, String message, Object... values)
Validate that the specified argument object fall between the two inclusive values specified; otherwise, throws an exception with the specified message.
Validate.inclusiveBetween(0, 2, 1, "Not in boundaries");
T
- the type of the argument objectlogger
- the logger via which to log the exceptionstart
- the inclusive start value, not nullend
- the inclusive end value, not nullvalue
- the object to validate, not nullmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendedIllegalArgumentException
- if the value falls out of the boundariesinclusiveBetween(Logger, Object, Object, Comparable)
public static <T> void inclusiveBetween(Logger logger, Level level, T start, T end, Comparable<T> value, String message, Object... values)
Validate that the specified argument object fall between the two inclusive values specified; otherwise, throws an exception with the specified message.
Validate.inclusiveBetween(0, 2, 1, "Not in boundaries");
T
- the type of the argument objectlogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionstart
- the inclusive start value, not nullend
- the inclusive end value, not nullvalue
- the object to validate, not nullmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendedIllegalArgumentException
- if the value falls out of the boundariesinclusiveBetween(Logger, Object, Object, Comparable)
public static <T> void exclusiveBetween(Logger logger, T start, T end, Comparable<T> value)
Validate that the specified argument object fall between the two exclusive values specified; otherwise, throws an exception.
Validate.inclusiveBetween(0, 2, 1);
T
- the type of the argument objectlogger
- the logger via which to log the exceptionstart
- the exclusive start value, not nullend
- the exclusive end value, not nullvalue
- the object to validate, not nullIllegalArgumentException
- if the value falls out of the boundariesexclusiveBetween(Logger, Object, Object, Comparable, String, Object...)
public static <T> void exclusiveBetween(Logger logger, Level level, T start, T end, Comparable<T> value)
Validate that the specified argument object fall between the two exclusive values specified; otherwise, throws an exception.
Validate.inclusiveBetween(0, 2, 1);
T
- the type of the argument objectlogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionstart
- the exclusive start value, not nullend
- the exclusive end value, not nullvalue
- the object to validate, not nullIllegalArgumentException
- if the value falls out of the boundariesexclusiveBetween(Logger, Object, Object, Comparable, String, Object...)
public static <T> void exclusiveBetween(Logger logger, T start, T end, Comparable<T> value, String message, Object... values)
Validate that the specified argument object fall between the two exclusive values specified; otherwise, throws an exception with the specified message.
Validate.inclusiveBetween(0, 2, 1, "Not in boundaries");
T
- the type of the argument objectlogger
- the logger via which to log the exceptionstart
- the exclusive start value, not nullend
- the exclusive end value, not nullvalue
- the object to validate, not nullmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendedIllegalArgumentException
- if the value falls out of the boundariesexclusiveBetween(Logger, Object, Object, Comparable)
public static <T> void exclusiveBetween(Logger logger, Level level, T start, T end, Comparable<T> value, String message, Object... values)
Validate that the specified argument object fall between the two exclusive values specified; otherwise, throws an exception with the specified message.
Validate.inclusiveBetween(0, 2, 1, "Not in boundaries");
T
- the type of the argument objectlogger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionstart
- the exclusive start value, not nullend
- the exclusive end value, not nullvalue
- the object to validate, not nullmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendedIllegalArgumentException
- if the value falls out of the boundariesexclusiveBetween(Logger, Object, Object, Comparable)
public static void isInstanceOf(Logger logger, Class<?> type, Object obj)
This method is useful when validating according to an arbitrary class
Validate.isInstanceOf(OkClass.class, object);
The message of the exception is "Expected type: {type}, actual: {obj_type}"
logger
- the logger via which to log the exceptiontype
- the class the object must be validated against, not nullobj
- the object to check, null throws an exceptionIllegalArgumentException
- if argument is not of specified classisInstanceOf(Logger, Class, Object, String, Object...)
public static void isInstanceOf(Logger logger, Level level, Class<?> type, Object obj)
This method is useful when validating according to an arbitrary class
Validate.isInstanceOf(OkClass.class, object);
The message of the exception is "Expected type: {type}, actual: {obj_type}"
logger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptiontype
- the class the object must be validated against, not nullobj
- the object to check, null throws an exceptionIllegalArgumentException
- if argument is not of specified classisInstanceOf(Logger, Class, Object, String, Object...)
public static void isInstanceOf(Logger logger, Class<?> type, Object obj, String message, Object... values)
Validate that the argument is an instance of the specified class; otherwise throwing an exception with the specified message. This method is useful when validating according to an arbitrary class
Validate.isInstanceOf(OkClass.classs, object, "Wrong class, object is of class %s", object.getClass().getName());
logger
- the logger via which to log the exceptiontype
- the class the object must be validated against, not nullobj
- the object to check, null throws an exceptionmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendedIllegalArgumentException
- if argument is not of specified classisInstanceOf(Logger, Class, Object)
public static void isInstanceOf(Logger logger, Level level, Class<?> type, Object obj, String message, Object... values)
Validate that the argument is an instance of the specified class; otherwise throwing an exception with the specified message. This method is useful when validating according to an arbitrary class
Validate.isInstanceOf(OkClass.classs, object, "Wrong class, object is of class %s", object.getClass().getName());
logger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptiontype
- the class the object must be validated against, not nullobj
- the object to check, null throws an exceptionmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendedIllegalArgumentException
- if argument is not of specified classisInstanceOf(Logger, Class, Object)
public static void isAssignableFrom(Logger logger, Class<?> superType, Class<?> type)
This method is useful when validating that there will be no casting errors.
Validate.isAssignableFrom(SuperClass.class, object.getClass());
The message format of the exception is "Cannot assign {type} to {superType}"
logger
- the logger via which to log the exceptionsuperType
- the class the class must be validated against, not nulltype
- the class to check, not nullIllegalArgumentException
- if type argument is not assignable to the specified superTypeisAssignableFrom(Logger, Class, Class, String, Object...)
public static void isAssignableFrom(Logger logger, Level level, Class<?> superType, Class<?> type)
This method is useful when validating that there will be no casting errors.
Validate.isAssignableFrom(SuperClass.class, object.getClass());
The message format of the exception is "Cannot assign {type} to {superType}"
logger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionsuperType
- the class the class must be validated against, not nulltype
- the class to check, not nullIllegalArgumentException
- if type argument is not assignable to the specified superTypeisAssignableFrom(Logger, Class, Class, String, Object...)
public static void isAssignableFrom(Logger logger, Class<?> superType, Class<?> type, String message, Object... values)
This method is useful when validating if there will be no casting errors.
Validate.isAssignableFrom(SuperClass.class, object.getClass());
The message of the exception is "The validated object can not be converted to the" followed by the name of the class and "class"
logger
- the logger via which to log the exceptionsuperType
- the class the class must be validated against, not nulltype
- the class to check, not nullmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendedIllegalArgumentException
- if argument can not be converted to the specified classisAssignableFrom(Logger, Class, Class)
public static void isAssignableFrom(Logger logger, Level level, Class<?> superType, Class<?> type, String message, Object... values)
This method is useful when validating if there will be no casting errors.
Validate.isAssignableFrom(SuperClass.class, object.getClass());
The message of the exception is "The validated object can not be converted to the" followed by the name of the class and "class"
logger
- the logger via which to log the exceptionlevel
- the level at which to log the exceptionsuperType
- the class the class must be validated against, not nulltype
- the class to check, not nullmessage
- the String.format(String, Object...)
exception message if invalid, not nullvalues
- the optional values for the formatted exception message, null array not recommendedIllegalArgumentException
- if argument can not be converted to the specified classisAssignableFrom(Logger, Class, Class)
Copyright (C) 2015-2017 The Helenus Driver Project Authors.