Package redempt.ordinate.constraint
Interface Constraint<T,V>
- Type Parameters:
T
- The sender typeV
- The type the constraint is applied to
public interface Constraint<T,V>
A predicate for a specific type that can return error messages
-
Method Summary
Modifier and TypeMethodDescriptionapply
(CommandContext<T> context, V value) Checks whether a value is validstatic <T,
V> Constraint<T, List<V>> listConstraint
(Constraint<T, V> constraint) Converts a constraint to one which can be applied to a list
-
Method Details
-
listConstraint
Converts a constraint to one which can be applied to a list- Type Parameters:
T
- The sender typeV
- The original type being constrained- Parameters:
constraint
- The constraint- Returns:
- The converted constraint which can constrain a list
-
apply
Checks whether a value is valid- Parameters:
context
- The context of command executionvalue
- The value to apply the constraint to- Returns:
- An error if the constraint check failed, otherwise null
-