Interface ValueParameter.Simple<T>

Type Parameters:
T - The type of object that is returned from the ValueParser upon successful parsing.
All Superinterfaces:
DefaultedRegistryValue, ValueCompleter, ValueParameter<T>, ValueParser<T>, ValueUsage
All Known Subinterfaces:
ResourceKeyedValueParameter<T>
Enclosing interface:
ValueParameter<T>

public static interface ValueParameter.Simple<T> extends ValueParameter<T>
A ValueParameter that does not rely on the CommandContext or Parameter.Key to parse its results.
  • Method Details

    • parseValue

      Optional<? extends T> parseValue(CommandCause commandCause, ArgumentReader.Mutable reader) throws ArgumentParseException
      Gets the value for this parameter.

      This should have no side effects on anything except on the state of the ArgumentReader.

      This element may return nothing in the form of an empty optional. This indicates that a parse succeeded, but no meaningful value was returned.

      Parameters:
      commandCause - The cause of this parse
      reader - The ArgumentReader that contains the unparsed arguments
      Returns:
      Returns the value(s)
      Throws:
      ArgumentParseException - if a parameter could not be parsed
    • parseValue

      default Optional<? extends T> parseValue(Parameter.Key<? super T> parameterKey, ArgumentReader.Mutable reader, CommandContext.Builder context) throws ArgumentParseException
      This should not be overridden by implementations of this class. If you wish to do so, implement ValueParameter instead. Gets the value for the parameter. This may return more than one value by adding additional values to the supplied CommandContext.Builder.

      This should have no side effects on anything except on the state of the ArgumentReader and, in rare cases, the CommandContext.Builder.

      This element may return nothing in the form of an empty optional. This indicates that a parse succeeded, but no meaningful value was returned, for example, the argument must be passed but it's not necessary for the associated CommandExecutor to know what the result of the parse was. The CommandContext.Builder may be updated in this case.

      While the CommandContext.Builder is provided, in general, you do not need to add the parsed value to it yourself, instead preferring to return your parsed value. It is permissible, however, to add additional information to the context should it be required.

      The Cause of this parse is provided in the CommandContext.Builder.

      Specified by:
      parseValue in interface ValueParser<T>
      Parameters:
      parameterKey - The Parameter.Key of the parameter being parsed
      reader - The ArgumentReader that contains the unparsed arguments
      context - The CommandContext containing the state about this command
      Returns:
      Returns the value(s)
      Throws:
      ArgumentParseException - if a parameter could not be parsed
    • complete

      List<CommandCompletion> complete(CommandCause context, String currentInput)
      Gets valid completions for this element, given the supplied CommandCause and current input for this element.
      Parameters:
      context - The CommandCause that contains the parsed arguments
      currentInput - The current input for this argument
      Returns:
      The list of values
    • complete

      default List<CommandCompletion> complete(CommandContext context, String currentInput)
      This should not be overridden by implementations of this class. If you wish to do so, implement ValueParameter instead. Gets valid completions for this element, given the supplied CommandContext and current input for this element.
      Specified by:
      complete in interface ValueCompleter
      Parameters:
      context - The CommandContext that contains the parsed arguments
      currentInput - The current input for this argument
      Returns:
      The list of values