public final class CheckParameterUtil extends java.lang.Object
| Modifier | Constructor and Description |
|---|---|
private |
CheckParameterUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
ensure(T obj,
java.lang.String parameterName,
java.util.function.Predicate<T> condition)
Ensures that a parameter is not null and that a certain condition holds.
|
static <T> void |
ensure(T obj,
java.lang.String parameterName,
java.lang.String conditionMsg,
java.util.function.Predicate<T> condition)
Ensures that a parameter is not null and that a certain condition holds.
|
static void |
ensureParameterNotNull(java.lang.Object value)
Ensures a parameter is not
null. |
static void |
ensureParameterNotNull(java.lang.Object value,
java.lang.String parameterName)
Ensures a parameter is not
null |
static void |
ensureThat(boolean condition,
java.lang.String message)
Ensures that the condition
condition holds. |
static void |
ensureThat(boolean condition,
java.util.function.Supplier<java.lang.String> messageSupplier)
Ensures that the condition
condition holds. |
private CheckParameterUtil()
public static <T> void ensure(T obj, java.lang.String parameterName, java.lang.String conditionMsg, java.util.function.Predicate<T> condition)
T - parameter typeobj - parameter valueparameterName - parameter nameconditionMsg - string, stating the conditioncondition - the condition to checkjava.lang.IllegalArgumentException - in case the object is null or the condition
is violatedpublic static <T> void ensure(T obj, java.lang.String parameterName, java.util.function.Predicate<T> condition)
T - parameter typeobj - parameter valueparameterName - parameter namecondition - the condition to checkjava.lang.IllegalArgumentException - in case the object is null or the condition
is violatedpublic static void ensureParameterNotNull(java.lang.Object value, java.lang.String parameterName)
nullvalue - The parameter to checkparameterName - The parameter namejava.lang.IllegalArgumentException - if the parameter is nullpublic static void ensureParameterNotNull(java.lang.Object value)
null. Can find line number in the stack trace, so parameter name is optionalvalue - The parameter to checkjava.lang.IllegalArgumentException - if the parameter is nullpublic static void ensureThat(boolean condition, java.lang.String message)
condition holds.condition - The condition to checkmessage - error messagejava.lang.IllegalArgumentException - if the condition does not holdensureThat(boolean, Supplier)public static void ensureThat(boolean condition, java.util.function.Supplier<java.lang.String> messageSupplier)
condition holds.
This method can be used when the message is not a plain string literal,
but somehow constructed. Using a Supplier improves the performance,
as the string construction is skipped when the condition holds.condition - The condition to checkmessageSupplier - supplier of the error messagejava.lang.IllegalArgumentException - if the condition does not hold