Interface CommandParameter

All Superinterfaces:
CommandAnnotationHolder, Comparable<CommandParameter>, PermissionHolder

public interface CommandParameter extends Comparable<CommandParameter>, PermissionHolder, CommandAnnotationHolder
Represents a parameter in a command method. This corresponds to a Parameter in a method.

Note: this class has a natural ordering that is inconsistent with equals.

  • Method Details

    • getName

      @NotNull @NotNull String getName()
      Returns the parameter name, either from the @Named annotation or the compiler-reserved name 'argN'.
      Returns:
      The parameter name
      See Also:
    • getDescription

      @Nullable @Nullable String getDescription()
      Returns the description of this parameter. This can be specified with Description.

      This may be leveraged by some platforms for completions or suggestions.

      Returns:
      The parameter description.
      See Also:
    • getMethodIndex

      int getMethodIndex()
      Returns the index of this parameter in the method.
      Returns:
      The index of this parameter
    • getCommandIndex

      int getCommandIndex()
      Returns the actual index of the parameter in the command.

      If this parameter does not ParameterResolver.mutatesArguments(), this will return -1.

      Returns:
      The command index
    • getType

      @NotNull @NotNull Class<?> getType()
      The runtime-present type of this parameter
      Returns:
      The parameter type
    • getFullType

      @NotNull @NotNull Type getFullType()
      Returns the full type of this parameter. For example, if this is a List<String> then this will return that full type.
      Returns:
      The full type, including generics.
    • getDefaultValue

      @NotNull @NotNull @Unmodifiable List<String> getDefaultValue()
      The default value. This is set when annotated by Default.
      Returns:
      The parameter's default value
    • consumesAllString

      boolean consumesAllString()
      Whether should this parameter consume all arguments that come after it.

      This will return true if, and only if this is the last parameter in the method and is annotated with Single.

      Returns:
      Whether should this parameter consume all arguments
    • getJavaParameter

      Parameter getJavaParameter()
      Returns the Java-counterpart parameter of this
      Returns:
      The reflection parameter
    • getSuggestionProvider

      @NotNull @NotNull SuggestionProvider getSuggestionProvider()
      Returns the SuggestionProvider of this parameter. If not specified, this will return SuggestionProvider.EMPTY.
      Returns:
      The parameter's suggestion provider.
    • getValidators

      @NotNull @NotNull @Unmodifiable List<ParameterValidator<Object>> getValidators()
      Returns all the validators of the parameter
      Returns:
      The parameter validators
    • isOptional

      boolean isOptional()
      Whether is this parameter optional or not. This is whether the parameter has the Optional annotation or not
      Returns:
      Whether is this parameter optional
    • isLastInMethod

      boolean isLastInMethod()
      Returns whether this parameter is the last in the method
      Returns:
      If this parameter is the last in method
    • isSwitch

      boolean isSwitch()
      Returns whether is this parameter a Switch parameter or not.
      Returns:
      Whether is this parameter a switch or not
    • getSwitchName

      @NotNull @NotNull String getSwitchName()
      Returns the name of the switch. Returns null if isSwitch() is false.
      Returns:
      The switch name, otherwise throws a IllegalStateException
      Throws:
      IllegalStateException - If this parameter is not a switch
    • isFlag

      boolean isFlag()
      Returns whether is this parameter a Flag parameter or not
      Returns:
      Whether is this parameter a flag or not
    • getFlagName

      @NotNull @NotNull String getFlagName()
      Returns the name of the flag. Returns null if isFlag() is false.
      Returns:
      The flag name, otherwise throws a IllegalStateException
      Throws:
      IllegalStateException - If this parameter is not a switch
    • getDefaultSwitch

      boolean getDefaultSwitch()
      Returns the default Switch.defaultValue() if the switch was not provided in the command.

      Note that this will return false if isSwitch() is false.

      Returns:
      The default switch value.
    • getResolver

      @NotNull <T> @NotNull ParameterResolver<T> getResolver()
      Returns the resolver for this parameter. See ParameterResolver for more information.
      Returns:
      The resolver
      See Also:
    • getCommandHandler

      @NotNull @NotNull CommandHandler getCommandHandler()
      Returns the command handler that instantiated this parameter
      Returns:
      The owning command handler
    • getDeclaringCommand

      @NotNull @NotNull ExecutableCommand getDeclaringCommand()
      Returns the command that declares this parameter
      Returns:
      The declaring command for this parameter
      Since:
      1.3.0
    • getPermission

      @NotNull @NotNull CommandPermission getPermission()
      Returns the required permission to access this parameter.

      Parameters by default inherit their parent getDeclaringCommand() permission, unless

      Specified by:
      getPermission in interface PermissionHolder
      Returns:
      The command permission