Interface Parameter.Value<T>
-
- Type Parameters:
T- The type of value returned from theValueParsers
- All Superinterfaces:
Parameter
- Enclosing interface:
- Parameter
public static interface Parameter.Value<T> extends Parameter
Represents aParameterthat attempts to parse an argument to obtain a value of typeT.This type of
Parameterwill attempt to parse an input using theValueParsers in the order that they are returned inparsers(). If aValueParserfails to parse an argument, the next in the list will be tried, if the finalValueParsercannot parse the argument, this element will throw aArgumentParseException.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceParameter.Value.Builder<T>Builds 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
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.ValueCompletercompleter()Gets theValueCompleterassociated with thisParameter.Value.Parameter.Key<T>key()The key that a parameter result is stored under.java.util.Optional<ValueParameterModifier<T>>modifier()Gets theValueParameterModifierthat affects this parameter, if any.voidparse(@NonNull ArgumentReader.Mutable reader, @NonNull CommandContext.Builder context)Parses the next element(s) in theCommandContext.java.util.Collection<ValueParser<? extends T>>parsers()TheValueParsers to use when parsing an argument.java.util.function.Predicate<CommandCause>requirement()java.lang.Stringusage(CommandCause cause)Gets the usage of this parameter.java.util.Optional<ValueUsage>valueUsage()Gets theValueUsageassociated with thisParameter.Value, if any was set.booleanwillConsumeAllRemaining()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()
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
java.util.Optional<ValueParameterModifier<T>> modifier()
Gets theValueParameterModifierthat affects this parameter, if any.- Returns:
- The
ValueParameterModifier, if set.
-
valueUsage
java.util.Optional<ValueUsage> valueUsage()
Gets theValueUsageassociated 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.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
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- 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
java.lang.String usage(CommandCause cause)
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
-
-