null argument causes a NullPointerException.null argument causes an IllegalArgumentException.IndexOutOfBoundsException.All exceptions messages are format strings as defined by the Java platform. For example:
Validate.isTrue(i > 0, "The value must be greater than zero: %d", i); Validate.notNull(surname, "The surname must not be %s", null);
#ThreadSafe#
String#format(String, Object...)
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static void | exclusiveBetween(final double
the exclusive start value. start, final double the exclusive end value. end, final double the value to validate. value)Validate that the specified primitive value falls between the two exclusive values specified; otherwise, throws an exception. |
| public static void | exclusiveBetween(final double
the exclusive start value. start, final double the exclusive end value. end, final double the value to validate. value, final String the exception message if invalid, not null. message)Validate that the specified primitive value falls between the two exclusive values specified; otherwise, throws an exception with the specified message. |
| public static void | exclusiveBetween(final long
the exclusive start value. start, final long the exclusive end value. end, final long the value to validate. value)Validate that the specified primitive value falls between the two exclusive values specified; otherwise, throws an exception. |
| public static void | exclusiveBetween(final long
the exclusive start value. start, final long the exclusive end value. end, final long the value to validate. value, final String the exception message if invalid, not null. message)Validate that the specified primitive value falls between the two exclusive values specified; otherwise, throws an exception with the specified message. |
| public static < the type of the argument object. T> void | exclusiveBetween(final T
the exclusive start value, not null. start, final T the exclusive end value, not null. end, final Comparable<T> the object to validate, not null. value)Validate that the specified argument object fall between the two exclusive values specified; otherwise, throws an exception. |
| public static < the type of the argument object. T> void | exclusiveBetween(final T
the exclusive start value, not null. start, final T the exclusive end value, not null. end, final Comparable<T> the object to validate, not null. value, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validate that the specified argument object fall between the two exclusive values specified; otherwise, throws an exception with the specified message. |
| public static void | finite(final double
the value to validate. value)Validates that the specified argument is not infinite or Not-a-Number (NaN); otherwise throwing an exception. |
| public static void | finite(final double
the value to validate. value, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message. values)Validates that the specified argument is not infinite or Not-a-Number (NaN); otherwise throwing an exception with the specified message. |
| private static String | Returns: formatted message usingString. if the values are not empty, otherwise return the
unformatted message.the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted message. values)Gets the message using |
| public static void | inclusiveBetween(final double
the inclusive start value. start, final double the inclusive end value. end, final double the value to validate. value)Validate that the specified primitive value falls between the two inclusive values specified; otherwise, throws an exception. |
| public static void | inclusiveBetween(final double
the inclusive start value. start, final double the inclusive end value. end, final double the value to validate. value, final String the exception message if invalid, not null. message)Validate that the specified primitive value falls between the two inclusive values specified; otherwise, throws an exception with the specified message. |
| public static void | inclusiveBetween(final long
the inclusive start value. start, final long the inclusive end value. end, final long the value to validate. value)Validate that the specified primitive value falls between the two inclusive values specified; otherwise, throws an exception. |
| public static void | inclusiveBetween(final long
the inclusive start value. start, final long the inclusive end value. end, final long the value to validate. value, final String the exception message if invalid, not null. message)Validate that the specified primitive value falls between the two inclusive values specified; otherwise, throws an exception with the specified message. |
| public static < the type of the argument object. T> void | inclusiveBetween(final T
the inclusive start value, not null. start, final T the inclusive end value, not null. end, final Comparable<T> the object to validate, not null. value)Validate that the specified argument object fall between the two inclusive values specified; otherwise, throws an exception. |
| public static < the type of the argument object. T> void | inclusiveBetween(final T
the inclusive start value, not null. start, final T the inclusive end value, not null. end, final Comparable<T> the object to validate, not null. value, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validate that the specified argument object fall between the two inclusive values specified; otherwise, throws an exception with the specified message. |
| public static void | isAssignableFrom(final Class<?>
the class must be validated against, not null. superType, final Class<?> the class to check, not null. type)Validates that the argument can be converted to the specified class, if not, throws an exception. |
| public static void | isAssignableFrom(final Class<?>
the class must be validated against, not null. superType, final Class<?> the class to check, not null. type, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validates that the argument can be converted to the specified class, if not throws an exception. |
| public static void | isInstanceOf(final Class<?>
the class the object must be validated against, not null. type, final Object the object to check, null throws an exception. obj)Validates that the argument is an instance of the specified class, if not throws an exception. |
| public static void | isInstanceOf(final Class<?>
the class the object must be validated against, not null. type, final Object the object to check, null throws an exception. obj, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validate that the argument is an instance of the specified class; otherwise throwing an exception with the specified message. |
| public static void | isTrue(final boolean
the boolean expression to check. expression)Validate that the argument condition is |
| public static void | isTrue(final boolean
the boolean expression to check. expression, final String the message, final double String#format(String, Object. exception message if invalid, not null.the value to append to the message when invalid. value)Validate that the argument condition is |
| public static void | isTrue(final boolean
the boolean expression to check. expression, final String the message, final long String#format(String, Object. exception message if invalid, not null.the value to append to the message when invalid. value)Validate that the argument condition is |
| public static void | isTrue(final boolean
the boolean expression to check. expression, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validate that the argument condition is |
| public static void | |
| public static void | matchesPattern(final CharSequence
the character sequence to validate, not null. input, final String the regular expression pattern, not null. pattern)Validate that the specified argument character sequence matches the specified regular expression pattern; otherwise throwing an exception. |
| public static void | matchesPattern(final CharSequence
the character sequence to validate, not null. input, final String the regular expression pattern, not null. pattern, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validate that the specified argument character sequence matches the specified regular expression pattern; otherwise throwing an exception with the specified message. |
| public static < the iterable type. T extends Iterable | Returns: the validated iterable (nevernull method for chaining).the iterable to check, validated not null by this method. iterable)Validate that the specified argument iterable is neither
|
| public static < the iterable type. T extends Iterable | Returns: the validated iterable (nevernull method for chaining).the iterable to check, validated not null by this method. iterable, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validate that the specified argument iterable is neither
|
| public static < the array type. T> T[] | Returns: the validated array (nevernull method for chaining).the array to check, validated not null by this method. array)Validate that the specified argument array is neither
|
| public static < the array type. T> T[] | Returns: the validated array (nevernull method for chaining).the array to check, validated not null by this method. array, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validate that the specified argument array is neither
|
| public static < the character sequence type. T extends CharSequence> T | Returns: the validated character sequence (nevernull method for chaining).the character sequence to check, validated not null by this method. chars)Validates that the specified argument character sequence is
neither |
| public static < the character sequence type. T extends CharSequence> T | Returns: the validated character sequence (nevernull method for chaining).the character sequence to check, validated not null by this method. chars, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validates that the specified argument character sequence is not |
| public static < the collection type. T extends Collection | Returns: the validated collection (nevernull method for chaining).the collection to check, validated not null by this method. collection)Validates that the specified argument collection is neither |
| public static < the map type. T extends Map | Returns: the validated map (nevernull method for chaining).the map to check, validated not null by this method. map)Validates that the specified argument map is neither |
| public static < the character sequence type. T extends CharSequence> T | Returns: the validated character sequence (nevernull method for chaining).the character sequence to check, validated not null by this method. chars)Validates that the specified argument character sequence is
neither |
| public static < the collection type. T extends Collection | Returns: the validated collection (nevernull method for chaining).the collection to check, validated not null by this method. collection, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validates that the specified argument collection is neither |
| public static < the map type. T extends Map | Returns: the validated map (nevernull method for chaining).the map to check, validated not null by this method. map, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validate that the specified argument map is neither |
| public static < the character sequence type. T extends CharSequence> T | Returns: the validated character sequence (nevernull method for chaining).the character sequence to check, validated not null by this method. chars, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validate that the specified argument character sequence is
neither |
| public static < the array type. T> T[] | Returns: the validated array (nevernull method for chaining).the array to check, validated not null by this method. array)Validates that the specified argument array is neither |
| public static < the array type. T> T[] | Returns: the validated array (nevernull method for chaining).the array to check, validated not null by this method. array, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validates that the specified argument array is neither |
| public static void | notNaN(final double
the value to validate. value)Validates that the specified argument is not Not-a-Number (NaN); otherwise throwing an exception. |
| public static void | notNaN(final double
the value to validate. value, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message. values)Validates that the specified argument is not Not-a-Number (NaN); otherwise throwing an exception with the specified message. |
| public static < the object type. T> T | Returns: the validated object (nevernull for method chaining).the object to check. object)
Deprecated
Use
Objects#requireNonNull(Object).
Validate that the specified argument is not |
| public static < the object type. T> T | Returns: the validated object (nevernull for method chaining).the object to check. object, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message. values)Validate that the specified argument is not |
| private static Supplier | |
| public static < the collection type. T extends Collection | Returns: the validated collection (nevernull for method chaining).the collection to check, validated not null by this method. collection, final int the index to check. index)Validates that the index is within the bounds of the argument collection; otherwise throwing an exception. |
| public static < the character sequence type. T extends CharSequence> T | Returns: the validated character sequence (nevernull for method chaining).the character sequence to check, validated not null by this method. chars, final int the index to check. index)Validates that the index is within the bounds of the argument character sequence; otherwise throwing an exception. |
| public static < the collection type. T extends Collection | Returns: the validated collection (nevernull for chaining).the collection to check, validated not null by this method. collection, final int the index to check. index, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validates that the index is within the bounds of the argument collection; otherwise throwing an exception with the specified message. |
| public static < the character sequence type. T extends CharSequence> T | Returns: the validated character sequence (nevernull for method chaining).the character sequence to check, validated not null by this method. chars, final int the index to check. index, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validates that the index is within the bounds of the argument character sequence; otherwise throwing an exception with the specified message. |
| public static < the array type. T> T[] | Returns: the validated array (nevernull for method chaining).the array to check, validated not null by this method. array, final int the index to check. index)Validates that the index is within the bounds of the argument array; otherwise throwing an exception. |
| public static < the array type. T> T[] | Returns: the validated array (nevernull for method chaining).the array to check, validated not null by this method. array, final int the index to check. index, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validates that the index is within the bounds of the argument array; otherwise throwing an exception with the specified message. |
| public static void | validState(final boolean
the boolean expression to check. expression)Validate that the stateful condition is |
| public static void | validState(final boolean
the boolean expression to check. expression, final String the message, final Object... String#format(String, Object. exception message if invalid, not null.the optional values for the formatted exception message, null array not recommended. values)Validate that the stateful condition is |