Class AbstractArgument<T>

java.lang.Object
io.github.mqzn.commands.arguments.AbstractArgument<T>
Type Parameters:
T - the data type of the argument parameter
All Implemented Interfaces:
Argument<T>
Direct Known Subclasses:
ArgumentBoolean, ArgumentEnum, ArgumentLiteral, ArgumentNumber, ArgumentStringArray, ArgumentWord

public abstract class AbstractArgument<T> extends Object implements Argument<T>
This class represents an argument as a command-syntax parameter to be used in usages and context parsing
  • Field Details

    • suggestions

      @NotNull protected final @NotNull List<T> suggestions
  • Constructor Details

    • AbstractArgument

      public AbstractArgument(@NotNull @NotNull String id, @NotNull @NotNull Class<T> type)
    • AbstractArgument

      public AbstractArgument(@NotNull @NotNull String id, @NotNull @NotNull Class<T> type, boolean optional, boolean useRemainingSpace)
    • AbstractArgument

      public AbstractArgument(String id, Class<T> type, boolean useRemainingSpace)
    • AbstractArgument

      public AbstractArgument(@NotNull @NotNull ArgumentData data, Class<T> type)
  • Method Details

    • id

      public String id()
      The id of the Required argument
      Specified by:
      id in interface Argument<T>
      Returns:
      the id of the Required argument
    • description

      public Optional<@Nullable String> description()
      The description of an argument
      Specified by:
      description in interface Argument<T>
      Returns:
      the description for usage
    • type

      public Class<T> type()
      The type of the argument
      Specified by:
      type in interface Argument<T>
      Returns:
      the class type of the argument
    • defaultValue

      @Nullable public T defaultValue()
      Description copied from interface: Argument
      The default value of this argument if the default value is null, means it has no default values, so it's a REQUIRED argument !
      Specified by:
      defaultValue in interface Argument<T>
      Returns:
      The default value of this argument
    • setDefaultValue

      @NotNull public @NotNull Argument<T> setDefaultValue(@Nullable T value)
      Description copied from interface: Argument
      Modifies the default value of the argument
      Specified by:
      setDefaultValue in interface Argument<T>
      Parameters:
      value - the new default value
    • isOptional

      public boolean isOptional()
      Specified by:
      isOptional in interface Argument<T>
    • setOptional

      public void setOptional(boolean optional)
      Specified by:
      setOptional in interface Argument<T>
    • asOptional

      public Argument<T> asOptional()
    • useRemainingSpace

      public boolean useRemainingSpace()
      Whether the argument can become greedy and use the remaining args till the end of the args
      Specified by:
      useRemainingSpace in interface Argument<T>
      Returns:
      Whether the argument can become greedy * and use the remaining args till the end of the args
    • description

      public Argument<T> description(@Nullable @Nullable String description)
      Specified by:
      description in interface Argument<T>
    • suggest

      public Argument<T> suggest(@NotNull T suggestion)
      Specified by:
      suggest in interface Argument<T>
    • suggestions

      @NotNull public @NotNull List<T> suggestions()
      Specified by:
      suggestions in interface Argument<T>
    • suggest

      @SafeVarargs public final Argument<T> suggest(@NotNull @NotNull T... suggestions)
      Specified by:
      suggest in interface Argument<T>
    • toString

      public String toString(T obj)
      Specified by:
      toString in interface Argument<T>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object