Interface CommandParameter<S extends Source>

All Superinterfaces:
DescriptionHolder, PermissionHolder
All Known Subinterfaces:
AnnotatedParameter<S>, Command<S>, FlagParameter<S>, NumericParameter<S>
All Known Implementing Classes:
AnnotationParameterDecorator, FlagCommandParameter, InputParameter, NumericParameterDecorator

@AvailableSince("1.0.0") public interface CommandParameter<S extends Source> extends PermissionHolder, DescriptionHolder
Represents the command parameter required by the usage of the command itself
  • Method Details

    • of

      static <S extends Source, T> CommandParameter<S> of(String name, ParameterType<S,T> type, @Nullable @Nullable String permission, Description description, boolean optional, boolean greedy, @NotNull @NotNull OptionalValueSupplier valueSupplier, @Nullable @Nullable SuggestionResolver<S> suggestionResolver)
    • required

      static <S extends Source, T> ParameterBuilder<S,T> required(String name, ParameterType<S,T> type)
    • requiredInt

      static <S extends Source> ParameterBuilder<S,Integer> requiredInt(String name)
    • requiredLong

      static <S extends Source> ParameterBuilder<S,Long> requiredLong(String name)
    • requiredDouble

      static <S extends Source> ParameterBuilder<S,Double> requiredDouble(String name)
    • requiredFloat

      static <S extends Source> ParameterBuilder<S,Float> requiredFloat(String name)
    • requiredBoolean

      static <S extends Source> ParameterBuilder<S,Boolean> requiredBoolean(String name)
    • requiredText

      static <S extends Source> ParameterBuilder<S,String> requiredText(String name)
    • requiredGreedy

      static <S extends Source> ParameterBuilder<S,String> requiredGreedy(String name)
    • optional

      static <S extends Source, T> ParameterBuilder<S,T> optional(String name, ParameterType<S,T> token)
    • optionalInt

      static <S extends Source> ParameterBuilder<S,Integer> optionalInt(String name)
    • optionalLong

      static <S extends Source> ParameterBuilder<S,Long> optionalLong(String name)
    • optionalDouble

      static <S extends Source> ParameterBuilder<S,Double> optionalDouble(String name)
    • optionalFloat

      static <S extends Source> ParameterBuilder<S,Float> optionalFloat(String name)
    • optionalBoolean

      static <S extends Source> ParameterBuilder<S,Boolean> optionalBoolean(String name)
    • optionalText

      static <S extends Source> ParameterBuilder<S,String> optionalText(String name)
    • optionalGreedy

      static <S extends Source> ParameterBuilder<S,String> optionalGreedy(String name)
    • flag

      static <S extends Source, T> FlagBuilder<S,T> flag(String name, ParameterType<S,T> inputType)
    • flagSwitch

      static <S extends Source> FlagBuilder<S,Boolean> flagSwitch(String name)
    • literal

      static <S extends Source> CommandParameter<S> literal(String part)
    • name

      String name()
      Returns:
      the name of the parameter
    • parent

      @Nullable @Nullable Command<S> parent()
      Returns:
      the parent of this parameter
    • parent

      void parent(Command<S> parentCommand)
      Sets parent command for a parameter
      Parameters:
      parentCommand - the parameter's owning command
    • position

      int position()
      Returns:
      the index of this parameter
    • position

      @Internal void position(int position)
      Sets the position of this parameter in a syntax DO NOT USE THIS FOR ANY REASON unless it's necessary to do so
      Parameters:
      position - the position to set
    • getSinglePermission

      @Nullable @Nullable String getSinglePermission()
      For parameters, ONLY one permission is allowed for each parameter.
      Returns:
      the single permission for this parameter.
    • setSinglePermission

      default void setSinglePermission(String permission)
    • wrappedType

      TypeWrap<?> wrappedType()
      Returns:
      the value valueType-token of this parameter
    • valueType

      default Type valueType()
      Returns:
      the value valueType of this parameter
    • type

      @NotNull @NotNull ParameterType<S,?> type()
      Retrieves the parameter type associated with this command parameter.
      Returns:
      the ParameterType of the command parameter
    • getDefaultValueSupplier

      @NotNull @NotNull OptionalValueSupplier getDefaultValueSupplier()
      Returns:
      the default value if it's input is not present in case of the parameter being optional
    • isOptional

      boolean isOptional()
      Returns:
      whether this is an optional argument
    • isFlag

      boolean isFlag()
      Returns:
      checks whether this parameter is a flag
    • asFlagParameter

      FlagParameter<S> asFlagParameter()
      Casts the parameter to a flag parameter
      Returns:
      the parameter as a flag
    • isGreedy

      boolean isGreedy()
      Returns:
      checks whether this parameter consumes all the args input after it.
    • isGreedyString

      boolean isGreedyString()
    • isCommand

      default boolean isCommand()
      Returns:
      checks whether this usage param is a command name
    • asCommand

      Command<S> asCommand()
      Casts the parameter to a subcommand/command
      Returns:
      the parameter as a command
    • isAnnotated

      default boolean isAnnotated()
      Returns:
      Whether this usage parameter has been constructed using the annotations through methods or not
    • asAnnotated

      default AnnotatedParameter<S> asAnnotated()
      Casts the parameter to a parameter with annotations
      Returns:
      the parameter as annotated one
      See Also:
    • getSuggestionResolver

      @Nullable @Nullable SuggestionResolver<S> getSuggestionResolver()
      Fetches the suggestion resolver linked to this command parameter.
      Returns:
      the SuggestionResolver for a resolving suggestion
    • format

      String format()
      Formats the usage parameter, the default value is the name of the parameter
      Returns:
      the formatted parameter
      See Also:
    • setFormat

      void setFormat(String format)
      Sets a custom format for this parameter the default value is the name of the parameter
      Parameters:
      format - the format to set
      See Also:
    • isNumeric

      default boolean isNumeric()
    • asNumeric

      default NumericParameter<S> asNumeric()
    • similarTo

      boolean similarTo(CommandParameter<?> parameter)
      Checks if this parameter has same name and valueType to the other CommandParameter unlike `CommandParameter#equals(Object)`, if both parameters are only different in their parent Command, it would still return true
      Parameters:
      parameter - the parameter to compare to
      Returns:
      Whether this parameter has same name and valueType to the other CommandParameter or not
    • isRequired

      default boolean isRequired()
    • copyWithDifferentPosition

      CommandParameter<S> copyWithDifferentPosition(int newPosition)
      Creates a copy of this parameter with a different position. Useful for commands that have multiple syntaxes.
      Parameters:
      newPosition - the new position to set
      Returns:
      a copy of this parameter with the new position