Interface Argument<T>

Type Parameters:
T - the data type of the argument parameter
All Known Implementing Classes:
AbstractArgument, ArgumentBoolean, ArgumentDouble, ArgumentEnum, ArgumentFloat, ArgumentInteger, ArgumentLiteral, ArgumentLong, ArgumentNumber, ArgumentStringArray, ArgumentWord

public interface Argument<T>
An interface to represent an argument as a command-syntax parameter to be used in usages and context parsing
  • Method Details

    • literal

      static ArgumentLiteral literal(String id)
      Parameters:
      id - the name of the argument
      Returns:
      creates a literal argument
    • word

      static ArgumentWord word(String id)
      Parameters:
      id - the name of the argument
      Returns:
      creates a word argument
    • Boolean

      static ArgumentBoolean Boolean(String id)
      Parameters:
      id - the name of the argument
      Returns:
      creates a boolean(true/false) argument
    • integer

      static ArgumentInteger integer(String id)
      Parameters:
      id - the name of the argument
      Returns:
      creates an integer argument
    • Double

      static ArgumentDouble Double(String id)
      Parameters:
      id - the name of the argument
      Returns:
      creates a double argument
    • Float

      static ArgumentFloat Float(String id)
      Parameters:
      id - the name of the argument
      Returns:
      creates a float argument
    • Long

      static ArgumentLong Long(String id)
      Parameters:
      id - the name of the argument
      Returns:
      creates a long argument
    • Array

      static ArgumentStringArray Array(String id)
      Parameters:
      id - the name of the argument
      Returns:
      creates an array argument from a greedy/long string
    • Enum

      static <E extends Enum<E>> ArgumentEnum<E> Enum(String id, Class<E> enumClass)
      Parameters:
      id - the name of the argument
      Returns:
      creates an enum-related argument
    • literal

      static ArgumentLiteral literal(@NotNull @NotNull ArgumentData data)
      Parameters:
      data - the data of the argument
      Returns:
      creates a literal argument
      See Also:
    • word

      static ArgumentWord word(@NotNull @NotNull ArgumentData data)
      Parameters:
      data - the data of the argument
      Returns:
      creates a word/string argument
      See Also:
    • Boolean

      static ArgumentBoolean Boolean(@NotNull @NotNull ArgumentData data)
      Parameters:
      data - the data of the argument
      Returns:
      creates a boolean(true/false) argument
      See Also:
    • integer

      static ArgumentInteger integer(@NotNull @NotNull ArgumentData data)
      Parameters:
      data - the data of the argument
      Returns:
      creates an integer argument
      See Also:
    • Double

      static ArgumentDouble Double(@NotNull @NotNull ArgumentData data)
      Parameters:
      data - the data of the argument
      Returns:
      creates a double argument
      See Also:
    • Float

      static ArgumentFloat Float(@NotNull @NotNull ArgumentData data)
      Parameters:
      data - the data of the argument
      Returns:
      creates a float argument
      See Also:
    • Long

      static ArgumentLong Long(ArgumentData data)
      Parameters:
      data - the data of the argument
      Returns:
      creates a long argument
      See Also:
    • Enum

      static <E extends Enum<E>> ArgumentEnum<E> Enum(ArgumentData data, Class<E> enumClass)
      Parameters:
      data - the data of the argument
      Returns:
      creates an enum argument
      See Also:
    • id

      String id()
      The id of the Required argument
      Returns:
      the id of the Required argument
    • description

      Optional<@Nullable String> description()
      The description of an argument
      Returns:
      the description for usage
    • type

      Class<T> type()
      The type of the argument
      Returns:
      the class type of the argument
    • useRemainingSpace

      boolean useRemainingSpace()
      Whether the argument can become greedy and use the remaining args till the end of the args
      Returns:
      Whether the argument can become greedy * and use the remaining args till the end of the args
    • defaultValue

      @Nullable T defaultValue()
      The default value of this argument if the default value is null, means it has no default values, so it's a REQUIRED argument !
      Returns:
      The default value of this argument
    • setDefaultValue

      @NotNull @NotNull Argument<T> setDefaultValue(T value)
      Modifies the default value of the argument
      Parameters:
      value - the new default value
    • parse

      <S> T parse(@UnknownNullability S sender, @NotNull @NotNull String command, @NotNull @NotNull String input) throws ArgumentParseException
      Parses the raw input into it's argument type The argument type must be registered and defined by the user
      Type Parameters:
      S - the sender type
      Parameters:
      sender - the sender of the command
      command - the command
      input - the raw argument
      Returns:
      the parsed object from raw
      Throws:
      ArgumentParseException - when it fails to parse the raw argument
    • isOptional

      default boolean isOptional()
      Returns:
      whether this argument is optional or not
    • setOptional

      void setOptional(boolean optional)
      Sets the argument to be optional or not
      Parameters:
      optional - whether it's gonna be optional or not
    • suggest

      Argument<T> suggest(@NotNull T suggestion)
      Adds a suggestion object into the argument for TAB-completion
      Parameters:
      suggestion - the suggestion to add
      Returns:
      builder-pattern
    • description

      Argument<T> description(@Nullable @Nullable String description)
      Sets the description of the argument
      Parameters:
      description - the new description of the argument
      Returns:
      builder-pattern
    • suggestions

      @NotNull @NotNull List<T> suggestions()
      Returns:
      the suggestions of this argument
    • suggest

      Argument<T> suggest(@NotNull @NotNull T... suggestions)
      Suggests multiple suggestions for this argument
      Parameters:
      suggestions - the suggestions to add
      Returns:
      builder-pattern
    • toString

      String toString(T obj)
      changes the type of argument's object to a string
      Parameters:
      obj - the object type of the argument
      Returns:
      object as string
    • alternativeTypes

      default Class<?>[] alternativeTypes()
      Alternative types that relate to similar data-type of the argument example-> boolean.class refers to Boolean.class
      Returns:
      the alternative data-types of this argument's data-types
    • isSuggestionDynamic

      default boolean isSuggestionDynamic()
      A dynamic suggestion is a type of suggestion in TAB-completion in which, the suggestion go through modifications and changes of its value through the app's run-time, so requires fetching/loading it actively.
      Returns:
      whether this argument is based on dynamic suggestions or not