Interface Parameter.Value<T>
-
- Type Parameters:
T
- The type of value returned from theValueParser
s
- All Superinterfaces:
Parameter
- Enclosing interface:
- Parameter
public static interface Parameter.Value<T> extends Parameter
Represents aParameter
that attempts to parse an argument to obtain a value of typeT
.This type of
Parameter
will attempt to parse an input using theValueParser
s in the order that they are returned inparsers()
. If aValueParser
fails to parse an argument, the next in the list will be tried, if the finalValueParser
cannot parse the argument, this element will throw aArgumentParseException
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Parameter.Value.Builder<T>
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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<CommandCompletion>
complete(@NonNull ArgumentReader.Immutable reader, @NonNull CommandContext context)
Returns potential completions of the current tokenized argument.ValueCompleter
completer()
Gets theValueCompleter
associated with thisParameter.Value
.Parameter.Key<T>
key()
The key that a parameter result is stored under.java.util.Optional<ValueParameterModifier<T>>
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
.java.util.Collection<ValueParser<? extends T>>
parsers()
TheValueParser
s to use when parsing an argument.java.util.function.Predicate<CommandCause>
requirement()
java.lang.String
usage(CommandCause cause)
Gets the usage of this parameter.java.util.Optional<ValueUsage>
valueUsage()
Gets theValueUsage
associated with thisParameter.Value
, if any was set.boolean
willConsumeAllRemaining()
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 Detail
-
key
Parameter.Key<T> key()
The key that a parameter result is stored under.- Returns:
- The key.
-
parsers
java.util.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
java.util.Optional<ValueParameterModifier<T>> modifier()
Gets theValueParameterModifier
that affects this parameter, if any.- Returns:
- The
ValueParameterModifier
, if set.
-
valueUsage
java.util.Optional<ValueUsage> valueUsage()
Gets theValueUsage
associated with thisParameter.Value
, if any was set.- Returns:
- The
ValueUsage
, if set.
-
requirement
java.util.function.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
java.util.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
java.lang.String usage(CommandCause cause)
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
-
-