Interface Parameter.Value<T>
- Type Parameters:
T
- The type of value returned from theValueParser
s
- 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 ValueParser
s 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
Modifier and TypeInterfaceDescriptionstatic interface
Builds aParameter
from 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 theValueCompleter
associated with thisParameter.Value
.key()
The key that a parameter result is stored under.modifier()
Gets theValueParameterModifier
that affects this parameter, if any.void
parse
(@NonNull ArgumentReader.Mutable reader, @NonNull CommandContext.Builder context) Parses the next element(s) in theCommandContext
.Collection<ValueParser<? extends T>>
parsers()
TheValueParser
s to use when parsing an argument.usage
(CommandCause cause) Gets the usage of this parameter.Gets theValueUsage
associated with thisParameter.Value
, if any was set.boolean
If 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()TheValueParser
s 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 theValueCompleter
associated with thisParameter.Value
.- Returns:
- The
ValueCompleter
.
-
modifier
Optional<ValueParameterModifier<T>> modifier()Gets theValueParameterModifier
that affects this parameter, if any.- Returns:
- The
ValueParameterModifier
, if set.
-
valueUsage
Optional<ValueUsage> valueUsage()Gets theValueUsage
associated 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.Mutable
containing the strings that need to be parsedcontext
- TheCommandContext.Builder
that 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
- TheArgumentReader
containing the strings that need to be parsedcontext
- TheCommandContext
that 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
- TheCommandCause
that 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
-