Package org.moeaframework.util.validate
Class Validate
java.lang.Object
org.moeaframework.util.validate.Validate
Static methods for creating validators of parameters, arguments, or inputs. Each method produces a validator for
a specific type. Additionally, when creating the validator, the name of the parameter, argument, or input is given
along with the value, which is used to format the error message.
All validators throw IllegalArgumentException
s if the conditions fail, though they may also throw
NullPointerException
for unexpected null
values.
-
Method Summary
Modifier and TypeMethodDescriptionstatic final <R> R
Always fails with the given message.static final DoubleValidator
Constructs a validator for a double value.static final IntegerValidator
Constructs a validator for an integer value.static final ProblemValidator
Constructs a validator for aProblem
.static final <T> ObjectValidator<T>
Constructs a validator for any generic object.
-
Method Details
-
that
Constructs a validator for a double value.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
- the validator
-
that
Constructs a validator for an integer value.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
- the validator
-
that
Constructs a validator for aProblem
.- Parameters:
name
- the parameter nameproblem
- the problem- Returns:
- the validator
-
that
Constructs a validator for any generic object.- Type Parameters:
T
- the type of the object- Parameters:
name
- the parameter namevalue
- the object- Returns:
- the validator
-
fail
Always fails with the given message.- Type Parameters:
R
- the return type- Parameters:
message
- the reason for the failure- Returns:
- this method never returns
-