Interface Parameter.Value<T>
- Type Parameters:
T- The type of value returned from theValueParsers
- All Superinterfaces:
Parameter
- Enclosing interface:
Parameter
Represents a
Parameter that attempts to parse an argument to
obtain a value of type T.
This type of Parameter will attempt to parse an input
using the ValueParsers in the order that they are returned in
parsers(). If a ValueParser fails to parse an
argument, the next in the list will be tried, if the final
ValueParser cannot parse the argument, this element will
throw a ArgumentParseException.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceBuilds aParameterfrom constituent components.Nested classes/interfaces inherited from interface org.spongepowered.api.command.parameter.Parameter
Parameter.Factory, Parameter.FirstOfBuilder, Parameter.Key<T>, Parameter.Multi, Parameter.SequenceBuilder, Parameter.Subcommand, Parameter.Value<T> -
Method Summary
Modifier and TypeMethodDescriptioncomplete(@NonNull ArgumentReader.Immutable reader, @NonNull CommandContext context) Returns potential completions of the current tokenized argument.Gets theValueCompleterassociated with thisParameter.Value.key()The key that a parameter result is stored under.modifier()Gets theValueParameterModifierthat affects this parameter, if any.voidparse(@NonNull ArgumentReader.Mutable reader, @NonNull CommandContext.Builder context) Parses the next element(s) in theCommandContext.Collection<ValueParser<? extends T>> parsers()TheValueParsers to use when parsing an argument.usage(CommandCause cause) Gets the usage of this parameter.Gets theValueUsageassociated with thisParameter.Value, if any was set.booleanIf set, this parameter will repeat until the argument string has been parsed.Methods inherited from interface org.spongepowered.api.command.parameter.Parameter
isOptional, isTerminal
-
Method Details
-
key
Parameter.Key<T> key()The key that a parameter result is stored under.- Returns:
- The key.
-
parsers
Collection<ValueParser<? extends T>> parsers()TheValueParsers to use when parsing an argument. They will be tried in this order.There must always be at least one
ValueParser. If this element is optional and has a default result, it will be the last element in the returnedCollection.- Returns:
- The parameters.
-
completer
ValueCompleter completer()Gets theValueCompleterassociated with thisParameter.Value.- Returns:
- The
ValueCompleter.
-
modifier
Optional<ValueParameterModifier<T>> modifier()Gets theValueParameterModifierthat affects this parameter, if any.- Returns:
- The
ValueParameterModifier, if set.
-
valueUsage
Optional<ValueUsage> valueUsage()Gets theValueUsageassociated with thisParameter.Value, if any was set.- Returns:
- The
ValueUsage, if set.
-
requirement
Predicate<CommandCause> requirement()- Returns:
- the predicate
-
parse
void parse(@NonNull ArgumentReader.Mutable reader, @NonNull CommandContext.Builder context) throws ArgumentParseException Parses the next element(s) in theCommandContext.- Parameters:
reader- TheArgumentReader.Mutablecontaining the strings that need to be parsedcontext- TheCommandContext.Builderthat contains the current state of the execution- Throws:
ArgumentParseException- thrown if the parameter could not be parsed
-
complete
List<CommandCompletion> complete(@NonNull ArgumentReader.Immutable reader, @NonNull CommandContext context) throws ArgumentParseException Returns potential completions of the current tokenized argument. The completion will be based onArgumentReader.remaining().- Parameters:
reader- TheArgumentReadercontaining the strings that need to be parsedcontext- TheCommandContextthat contains the current state of the execution.- Returns:
- The potential completions.
- Throws:
ArgumentParseException- thrown if the parameter could not be parsed
-
usage
Gets the usage of this parameter.- Parameters:
cause- TheCommandCausethat requested the usage- Returns:
- The usage
-
willConsumeAllRemaining
boolean willConsumeAllRemaining()If set, this parameter will repeat until the argument string has been parsed.- Returns:
- if true, consumes all arguments
-