Interface ValueConstraint<T>
- Type Parameters:
T- the value type
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
For constraining the set of allowed values.
-
Method Summary
Modifier and TypeMethodDescriptiondefault ValueConstraint<Optional<T>> Converts thisValueConstraint<T>toValueConstraint<Optional<T>>.Returns the list of allowed values, if available.default @Nullable StringgetAllowedValuesDescription(ValueStringifier<T> stringifier) Returns a description of the allowed values.default booleanTests if a value is allowed.@Nullable StringChecks if a value is valid.default ValueConstraint<T> withExtraValidation(ValueConstraint<T> extraConstraint) Creates a new composite constraint.
-
Method Details
-
validate
Checks if a value is valid.- Parameters:
value- the value to check- Returns:
nullif valid, an error message if invalid
-
isValid
Tests if a value is allowed.- Parameters:
value- a value- Returns:
trueis the value is allowed
-
getAllowedValuesDescription
Returns a description of the allowed values.- Parameters:
stringifier- for converting values to strings- Returns:
- a description of the allowed values
-
getAllowedValues
Returns the list of allowed values, if available.- Returns:
- the list of allowed values, or
nullif not available
-
forOptionalValues
Converts thisValueConstraint<T>toValueConstraint<Optional<T>>.- Returns:
- the new constraint for optional values
-
withExtraValidation
Creates a new composite constraint.- Parameters:
extraConstraint- an additional constraint- Returns:
- the combined constraint
-