public final class Check
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
optional(T value,
java.lang.String parameterName,
java.util.function.Consumer<? super T>... validators)
Perform checks on an optional value.
|
static <T> T |
required(T value,
java.lang.String parameterName,
java.util.function.Consumer<? super T>... validators)
Perform checks on a required value (must not be null).
|
@SafeVarargs
public static <T> T optional(T value,
java.lang.String parameterName,
java.util.function.Consumer<? super T>... validators)
IllegalArgumentException will be thrown, including the parameter name an
error message.T - value typevalue - value to be checkedparameterName - parameter name of the value (will be included in the error message)validators - optional validators which perform checks on the value (only called when the value is not
null), and throw any Exception (will be converted to an IllegalArgumentException
with the same message) when the validation fails.@SafeVarargs
public static <T> T required(T value,
java.lang.String parameterName,
java.util.function.Consumer<? super T>... validators)
IllegalArgumentException will be thrown, including the parameter name an
error message.T - value typevalue - value to be checkedparameterName - parameter name of the value (will be included in the error message)validators - optional validators which perform checks on the value (only called when the value is not
null), and throw any Exception (will be converted to an IllegalArgumentException
with the same message) when the validation fails.