Interface Constraint<T,V>

Type Parameters:
T - The sender type
V - 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 Type
    Method
    Description
    apply(CommandContext<T> context, V value)
    Checks whether a value is valid
    static <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

      static <T, V> Constraint<T,List<V>> listConstraint(Constraint<T,V> constraint)
      Converts a constraint to one which can be applied to a list
      Type Parameters:
      T - The sender type
      V - The original type being constrained
      Parameters:
      constraint - The constraint
      Returns:
      The converted constraint which can constrain a list
    • apply

      Message<T> apply(CommandContext<T> context, V value)
      Checks whether a value is valid
      Parameters:
      context - The context of command execution
      value - The value to apply the constraint to
      Returns:
      An error if the constraint check failed, otherwise null