Class Constraint<T>

java.lang.Object
redempt.redlib.commandmanager.Constraint<T>
Type Parameters:
T - The type this Constraint checks on

public class Constraint<T> extends Object
Represents a condition which can be tested on command arguments, and can dynamically generate error messages
  • Method Details

    • of

      public static <T> Constraint<T> of(String error, BiPredicate<org.bukkit.command.CommandSender,T> condition)
      Create a Constraint
      Type Parameters:
      T - The type of the constraint
      Parameters:
      error - The error message to show when the constraint fails
      condition - A predicate to perform the constraint check on a converted argument
      Returns:
      A constructed Constraint
    • of

      public static <T> Constraint<T> of(BiPredicate<org.bukkit.command.CommandSender,T> condition)
      Create a Constraint
      Type Parameters:
      T - The type of the constraint
      Parameters:
      condition - A predicate to perform the constraint check on a converted argument
      Returns:
      A constructed Constraint
    • of

      public static <T> Constraint<T> of(Function<T,String> error, BiPredicate<org.bukkit.command.CommandSender,T> condition)
      Create a Constraint
      Type Parameters:
      T - The type of the constraint
      Parameters:
      error - A function to generate the error to be shown on constraint fail
      condition - A predicate to perform the constraint check on a converted argument
      Returns:
      A constructed Constraint
    • of

      public static <T> Constraint<T> of(BiFunction<org.bukkit.command.CommandSender,T,String> error, BiPredicate<org.bukkit.command.CommandSender,T> condition)
      Create a Constraint
      Type Parameters:
      T - The type of the constraint
      Parameters:
      error - A function to generate the error to be shown on constraint fail
      condition - A predicate to perform the constraint check on a converted argument
      Returns:
      A constructed Constraint
    • setName

      public Constraint<T> setName(String name)
    • getName

      public String getName()
    • test

      public boolean test(org.bukkit.command.CommandSender sender, Object arg)
    • getError

      public String getError(org.bukkit.command.CommandSender sender, Object arg)