Interface Parameter
- All Known Subinterfaces:
Parameter.Multi,Parameter.Subcommand,Parameter.Value<T>
Parameters that parse input and return an object into the
CommandContext should be of type Parameter.Value in
order to maximize type safety. However, there are also other important
ways that parameters can be used:
firstOfBuilder(Parameter)allows for multiple parameters that do not have the same return type to attempt to parse an input successfully.seqBuilder(Parameter)allows for the grouping of multiple parameters that will be executed one after another.Parameter.Subcommands can be placed anywhere in a parameter chain where aParametercan be added, if successfully parsed, any containingCommandwould take precedence and itsCommand.process(CommandCause, ArgumentReader.Mutable)method will be called instead of any parent.
Parameters are intended for use with Command.Builders.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceContains methods to create the generic builders.static interfaceSpecifies a builder for creating aParameterthat returns a parameter that concatenates all parameters into a single parameter to be executed one by one.static interfacestatic interfaceA parameter that consists of multiple parametersstatic interfaceSpecifies a builder for creating aParameterthat returns a parameter that concatenates all parameters into a single parameter to be executed one by one.static interfaceAParameter.Subcommandrepresents a literal argument where, if parsed, should indicate to the command processor that theCommandExecutorof the command should change.static interfaceRepresents aParameterthat attempts to parse an argument to obtain a value of typeT. -
Method Summary
Modifier and TypeMethodDescriptionstatic Parameter.Value.Builder<BigDecimal>Creates a builder that has theValueParameterset toResourceKeyedValueParameters.BIG_DECIMAL.static Parameter.Value.Builder<BigInteger>Creates a builder that has theValueParameterset toResourceKeyedValueParameters.BIG_INTEGER.static Parameter.Value.Builder<BlockState>Creates a builder that has theValueParameterset toResourceKeyedValueParameters.BLOCK_STATE.static Parameter.Value.Builder<Boolean>bool()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.BOOLEAN.static <T> Parameter.Value.Builder<T>builder(@NonNull io.leangen.geantyref.TypeToken<T> typeToken) Gets a builder that builds aParameter.Value.static <T,V extends ValueParameter<T>>
Parameter.Value.Builder<T>Gets a builder that builds aParameter.Value.static <T> Parameter.Value.Builder<T>builder(@NonNull io.leangen.geantyref.TypeToken<T> typeToken, @NonNull ValueParameter<? extends T> parameter) Gets a builder that builds aParameter.Value.static <T> Parameter.Value.Builder<T>Gets a builder that builds aParameter.Value.static <T> Parameter.Value.Builder<T>builder(@NonNull Class<T> valueClass, @NonNull ValueParameter<? extends T> parameter) Gets a builder that builds aParameter.Value.static <T,V extends ValueParameter<T>>
Parameter.Value.Builder<T>builder(@NonNull Class<T> valueClass, @NonNull DefaultedRegistryReference<V> parameter) Gets a builder that builds aParameter.Value.static <T> Parameter.Value.Builder<T>builder(@NonNull Parameter.Key<T> key) Gets a builder that builds aParameter.Value.static <T> Parameter.Value.Builder<T>choices(@NonNull Class<T> returnType, @NonNull Function<String, ? extends T> valueFunction, @NonNull Supplier<? extends Collection<String>> choices) Creates a builder that has aValueParameterthat allows you to specify a set of choices that must be chosen from.static <T> Parameter.Value.Builder<T>Creates a builder that has aValueParameterthat allows you to specify a set of choices that must be chosen from.static Parameter.Value.Builder<String>Creates a builder that has aValueParameterthat allows you to specify a set of choices that must be chosen fromstatic Parameter.Value.Builder<Color>color()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.COLOR.static Parameter.Value.Builder<DataContainer>Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DATA_CONTAINER.static Parameter.Value.Builder<LocalDateTime>dateTime()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DATE_TIME.static Parameter.Value.Builder<Double>Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DOUBLE.static Parameter.Value.Builder<Duration>duration()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DURATION.static Parameter.Value.Builder<Entity>entity()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.ENTITY.static Parameter.Value.Builder<Entity>Creates a builder that has theValueParameterset toResourceKeyedValueParameters.ENTITYstatic <T extends Enum<T>>
Parameter.Value.Builder<T>Creates a builder that has aValueParameterthat requires an argument that matches the name of a suppliedEnumtypestatic ParameterReturns aParameterthat attempts to parse an argument using the supplied parameters in order.static ParameterReturns aParameterthat attempts to parse an argument using the supplied parameters in order.static Parameter.FirstOfBuilderfirstOfBuilder(@NonNull Parameter parameter) Returns aParameter.FirstOfBuilderthat allows plugins to attempt to parse an argument using the supplied parameters in order.static Parameter.Value.Builder<Component>Creates a builder that has theValueParameterset toResourceKeyedValueParameters.TEXT_FORMATTING_CODE.static Parameter.Value.Builder<Component>Creates a builder that has theValueParameterset toResourceKeyedValueParameters.TEXT_FORMATTING_CODE_ALL.static Parameter.Value.Builder<Integer>Creates a builder that has theValueParameterset toResourceKeyedValueParameters.INTEGER.static Parameter.Value.Builder<InetAddress>ip()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.IP.booleanGets whether this parameter is optional.booleanGets whether this parameter is known to be able to be explicitly considered a terminal parameter without regarding its place in a command.Creates a builder that has theValueParameterset toResourceKeyedValueParameters.ITEM_STACK_SNAPSHOT.static Parameter.Value.Builder<Component>jsonText()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.TEXT_JSON.static Parameter.Value.Builder<Component>Creates a builder that has theValueParameterset toResourceKeyedValueParameters.TEXT_JSON_ALL.static <T> Parameter.Key<T>Creates aParameter.Keyfor storing values against.static <T> Parameter.Key<T>Creates aParameter.Keyfor storing values against.static <T> Parameter.Value.Builder<T>literal(@NonNull Class<T> returnType, @NonNull T returnedValue, @NonNull Supplier<? extends Collection<String>> literalSupplier) Creates a builder that has aValueParameterthat requires an argument to be a literal specifiedstatic <T> Parameter.Value.Builder<T>Creates a builder that has aValueParameterthat requires an argument to be a literal specifiedlocation()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.LOCATION.static Parameter.Value.Builder<Long>Creates a builder that has theValueParameterset toResourceKeyedValueParameters.LONG.static Parameter.Value.Builder<Operator>operator()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.OPERATOR.static Parameter.Value.Builder<ServerPlayer>player()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.PLAYER.static Parameter.Value.Builder<ServerPlayer>Creates a builder that has theValueParameterset toResourceKeyedValueParameters.PLAYER, else the targetstatic Parameter.Value.Builder<org.spongepowered.plugin.PluginContainer>plugin()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.PLUGIN.static Parameter.Value.Builder<Double>rangedDouble(double min, double max) Creates a builder that has theValueParameterset toVariableValueParameters.doubleRange(), using the specified bounds (inclusive).static Parameter.Value.Builder<Integer>rangedInteger(int min, int max) Creates a builder that has theValueParameterset toVariableValueParameters.integerRange(), using the specified bounds (inclusive).static <T> Parameter.Value.Builder<T>registryElement(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull List<Function<CommandContext, @Nullable RegistryHolder>> holderProviders, @NonNull RegistryType<T> registryKey, @NonNull String @NonNull ... defaultNamespaces) Creates a builder that has theValueParameterthat allows you to choose from cataloged types.static <T> Parameter.Value.Builder<T>registryElement(io.leangen.geantyref.TypeToken<T> type, @NonNull Function<CommandContext, @Nullable RegistryHolder> holderProvider, @NonNull RegistryType<T> registryKey, @NonNull String @NonNull ... defaultNamespaces) Creates a builder that has theValueParameterthat allows you to choose from cataloged types.static <T> Parameter.Value.Builder<T>registryElement(io.leangen.geantyref.TypeToken<T> type, @NonNull DefaultedRegistryType<T> registryType, @NonNull String @NonNull ... defaultNamespaces) Creates a builder that has theValueParameterthat allows you to choose from types registered in a givenRegistry.static Parameter.Value.Builder<String>Creates a builder that has theValueParameterset toResourceKeyedValueParameters.REMAINING_JOINED_STRINGS.static Parameter.Value.Builder<ResourceKey>Creates a builder that has theValueParameterset toResourceKeyedValueParameters.RESOURCE_KEY.static Parameter.Value.Builder<Vector3d>rotation()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.ROTATION.static ParameterReturns aParameterthat parses arguments using the supplied parameters in order.static ParameterReturns aParameterthat parses arguments using the supplied parameters in order.static Parameter.SequenceBuilderseqBuilder(@NonNull Parameter parameter) Returns aParameter.SequenceBuilderthat parses arguments using the supplied parameters in order.static Parameter.Value.Builder<String>string()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.STRING.static Parameter.Subcommandsubcommand(@NonNull Command.Parameterized subcommand, @NonNull String alias, String @NonNull ... aliases) Gets aParameterthat represents a subcommand.static Parameter.Value.Builder<URL>url()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.URL.static Parameter.Value.Builder<UUID>user()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.USER.static Parameter.Value.Builder<UUID>uuid()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.UUID.static Parameter.Value.Builder<Vector3d>vector3d()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.VECTOR3D.static Parameter.Value.Builder<ServerWorld>world()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.WORLD.
-
Method Details
-
key
static <T> Parameter.Key<T> key(@NonNull String key, @NonNull io.leangen.geantyref.TypeToken<T> typeToken) Creates aParameter.Keyfor storing values against.- Type Parameters:
T- The type- Parameters:
key- The string keytypeToken- The type of value that this key represents- Returns:
- The
Parameter.Key
-
key
Creates aParameter.Keyfor storing values against.- Type Parameters:
T- The type- Parameters:
key- The string keytype- The type of value that this key represents. Must not omit any type parameters.- Returns:
- The
Parameter.Key
-
builder
Gets a builder that builds aParameter.Value.If your parameter type is generic, use
builder(TypeToken)instead.- Type Parameters:
T- The type of parameter- Parameters:
valueClass- The type of value class- Returns:
- The
Parameter.Value.Builder
-
builder
Gets a builder that builds aParameter.Value.- Type Parameters:
T- The type of parameter- Parameters:
typeToken- The type of value class as aTypeToken- Returns:
- The
Parameter.Value.Builder
-
builder
Gets a builder that builds aParameter.Value.- Type Parameters:
T- The type of parameter- Parameters:
key- The key to initialize this builder with- Returns:
- The
Parameter.Value.Builder
-
builder
static <T> Parameter.Value.Builder<T> builder(@NonNull Class<T> valueClass, @NonNull ValueParameter<? extends T> parameter) Gets a builder that builds aParameter.Value.If your parameter type is generic, use
builder(TypeToken, ValueParameter)instead.- Type Parameters:
T- The type of parameter- Parameters:
valueClass- The type of value class as aClassparameter- The value parameter- Returns:
- The
Parameter.Value.Builder
-
builder
static <T> Parameter.Value.Builder<T> builder(@NonNull io.leangen.geantyref.TypeToken<T> typeToken, @NonNull ValueParameter<? extends T> parameter) Gets a builder that builds aParameter.Value.- Type Parameters:
T- The type of parameter- Parameters:
typeToken- The type of value class as aTypeTokenparameter- The value parameter- Returns:
- The
Parameter.Value.Builder
-
builder
static <T,V extends ValueParameter<T>> Parameter.Value.Builder<T> builder(@NonNull Class<T> valueClass, @NonNull DefaultedRegistryReference<V> parameter) Gets a builder that builds aParameter.Value.- Type Parameters:
T- The type of parameterV- TheValueParameterto be used as a parser- Parameters:
parameter- The value parametervalueClass- The type of value class- Returns:
- The
Parameter.Value.Builder
-
builder
static <T,V extends ValueParameter<T>> Parameter.Value.Builder<T> builder(@NonNull io.leangen.geantyref.TypeToken<T> typeToken, @NonNull Supplier<V> parameter) Gets a builder that builds aParameter.Value.- Type Parameters:
T- The type of parameterV- TheValueParameterto be used as a parser- Parameters:
parameter- The value parametertypeToken- The type of value class as aTypeToken- Returns:
- The
Parameter.Value.Builder
-
subcommand
static Parameter.Subcommand subcommand(@NonNull Command.Parameterized subcommand, @NonNull String alias, String @NonNull ... aliases) Gets aParameterthat represents a subcommand.If a
Parameter.Subcommandalias in a parameter chain is successfully matched, then element parsing will continue with the parameters supplied toCommand. It is implementation dependent as to what happens if a subcommand fails to parse.- Parameters:
subcommand- TheCommandto executealias- The first alias of the subcommandaliases- Subsequent aliases, if any- Returns:
- The
Parameter.Subcommandfor use in aParameterchain
-
firstOfBuilder
Returns aParameter.FirstOfBuilderthat allows plugins to attempt to parse an argument using the supplied parameters in order. Once a parameter has parsed the argument successfully, no more parameters supplied here will be attempted.- Parameters:
parameter- The firstParameter- Returns:
- The
Parameter.FirstOfBuilderto continue chaining
-
firstOf
static Parameter firstOf(@NonNull Parameter first, @NonNull Parameter second, Parameter @NonNull ... parameters) Returns aParameterthat attempts to parse an argument using the supplied parameters in order. Once a parameter has parsed the argument successfully, no more parameters supplied here will be attempted. -
firstOf
Returns aParameterthat attempts to parse an argument using the supplied parameters in order. Once a parameter has parsed the argument successfully, no more parameters supplied here will be attempted. -
seqBuilder
Returns aParameter.SequenceBuilderthat parses arguments using the supplied parameters in order.- Parameters:
parameter- The firstParameterin the sequence- Returns:
- The
Parameter.SequenceBuilder, to continue building the chain
-
seq
static Parameter seq(@NonNull Parameter first, @NonNull Parameter second, Parameter @NonNull ... parameters) Returns aParameterthat parses arguments using the supplied parameters in order. -
seq
Returns aParameterthat parses arguments using the supplied parameters in order. -
bigDecimal
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.BIG_DECIMAL.- Returns:
- A
Parameter.Value.Builder
-
bigInteger
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.BIG_INTEGER.- Returns:
- A
Parameter.Value.Builder
-
blockState
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.BLOCK_STATE.- Returns:
- A
Parameter.Value.Builder
-
bool
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.BOOLEAN.- Returns:
- A
Parameter.Value.Builder
-
color
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.COLOR.- Returns:
- A
Parameter.Value.Builder
-
dataContainer
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DATA_CONTAINER.- Returns:
- A
Parameter.Value.Builder
-
dateTime
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DATE_TIME.- Returns:
- A
Parameter.Value.Builder
-
duration
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DURATION.- Returns:
- A
Parameter.Value.Builder
-
doubleNumber
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DOUBLE.- Returns:
- A
Parameter.Value.Builder
-
entity
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.ENTITY.- Returns:
- A
Parameter.Value.Builder
-
entityOrTarget
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.ENTITY- Returns:
- A
Parameter.Value.Builder
-
formattingCodeText
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.TEXT_FORMATTING_CODE.- Returns:
- A
Parameter.Value.Builder
-
formattingCodeTextOfRemainingElements
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.TEXT_FORMATTING_CODE_ALL.- Returns:
- A
Parameter.Value.Builder
-
integerNumber
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.INTEGER.- Returns:
- A
Parameter.Value.Builder
-
ip
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.IP.- Returns:
- A
Parameter.Value.Builder
-
itemStackSnapshot
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.ITEM_STACK_SNAPSHOT.- Returns:
- A
Parameter.Value.Builder
-
jsonText
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.TEXT_JSON.- Returns:
- A
Parameter.Value.Builder
-
jsonTextOfRemainingElements
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.TEXT_JSON_ALL.- Returns:
- A
Parameter.Value.Builder
-
location
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.LOCATION.- Returns:
- A
Parameter.Value.Builder
-
longNumber
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.LONG.- Returns:
- A
Parameter.Value.Builder
-
operator
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.OPERATOR.- Returns:
- A
Parameter.Value.Builder
-
player
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.PLAYER.- Returns:
- A
Parameter.Value.Builder
-
playerOrTarget
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.PLAYER, else the target- Returns:
- A
Parameter.Value.Builder
-
plugin
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.PLUGIN.- Returns:
- A
Parameter.Value.Builder
-
rangedDouble
Creates a builder that has theValueParameterset toVariableValueParameters.doubleRange(), using the specified bounds (inclusive).- Parameters:
min- The minimum value.max- The maximum value.- Returns:
- A
Parameter.Value.Builder
-
rangedInteger
Creates a builder that has theValueParameterset toVariableValueParameters.integerRange(), using the specified bounds (inclusive).- Parameters:
min- The minimum value.max- The maximum value.- Returns:
- A
Parameter.Value.Builder
-
remainingJoinedStrings
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.REMAINING_JOINED_STRINGS.- Returns:
- A
Parameter.Value.Builder
-
resourceKey
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.RESOURCE_KEY.- Returns:
- A
Parameter.Value.Builder
-
rotation
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.ROTATION.- Returns:
- A
Parameter.Value.Builder
-
string
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.STRING.- Returns:
- A
Parameter.Value.Builder
-
url
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.URL.- Returns:
- A
Parameter.Value.Builder
-
user
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.USER.- Returns:
- A
Parameter.Value.Builder
-
uuid
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.UUID.- Returns:
- A
Parameter.Value.Builder
-
vector3d
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.VECTOR3D.- Returns:
- A
Parameter.Value.Builder
-
world
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.WORLD.- Returns:
- A
Parameter.Value.Builder
-
registryElement
static <T> Parameter.Value.Builder<T> registryElement(io.leangen.geantyref.TypeToken<T> type, @NonNull Function<CommandContext, @Nullable RegistryHolder> holderProvider, @NonNull RegistryType<T> registryKey, @NonNull String @NonNull ... defaultNamespaces) Creates a builder that has theValueParameterthat allows you to choose from cataloged types.See
#defaultNamespace(String)for how default namespaces work.If the
GameorServerscopedRegistryHolderis required,VariableValueParameters.RegistryEntryBuilder.GLOBAL_HOLDER_PROVIDERorVariableValueParameters.RegistryEntryBuilder.SERVER_HOLDER_PROVIDERmay be used.- Type Parameters:
T- The type of registry value- Parameters:
type- The registry value type to check for choicesholderProvider- AFunctionthat provides the appropriateRegistryHolderto get the appropriateRegistryregistryKey- TheRegistryKeythat represents the targetRegistrydefaultNamespaces- The default namespaces that will be used with the provided value if the supplied argument is un-namespaced- Returns:
- A
Parameter.Value.Builder
-
registryElement
static <T> Parameter.Value.Builder<T> registryElement(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull List<Function<CommandContext, @Nullable RegistryHolder>> holderProviders, @NonNull RegistryType<T> registryKey, @NonNull String @NonNull ... defaultNamespaces) Creates a builder that has theValueParameterthat allows you to choose from cataloged types.See
#defaultNamespace(String)for how default namespaces work.If the
GameorServerscopedRegistryHolderis required,VariableValueParameters.RegistryEntryBuilder.GLOBAL_HOLDER_PROVIDERorVariableValueParameters.RegistryEntryBuilder.SERVER_HOLDER_PROVIDERmay be used.- Type Parameters:
T- The type of registry value- Parameters:
type- The registry value type to check for choicesholderProviders-Functions that provides the appropriateRegistryHolderto get the appropriateRegistryregistryKey- TheRegistryKeythat represents the targetRegistrydefaultNamespaces- The default namespaces that will be used with the provided value if the supplied argument is un-namespaced- Returns:
- A
Parameter.Value.Builder
-
registryElement
static <T> Parameter.Value.Builder<T> registryElement(io.leangen.geantyref.TypeToken<T> type, @NonNull DefaultedRegistryType<T> registryType, @NonNull String @NonNull ... defaultNamespaces) Creates a builder that has theValueParameterthat allows you to choose from types registered in a givenRegistry.See
#defaultNamespace(String)for how default namespaces work.- Type Parameters:
T- The type of registyr value- Parameters:
type- The registry value type to check for choicesregistryType- TheDefaultedRegistryTypeto use when retrieving objectsdefaultNamespaces- The default namespaces that will be used with the provided value if the supplied argument is un-namespaced- Returns:
- A
Parameter.Value.Builder
-
choices
Creates a builder that has aValueParameterthat allows you to specify a set of choices that must be chosen fromThis will return a parser that will return
Strings- Parameters:
choices- The choices- Returns:
- A
Parameter.Value.Builder
-
choices
static <T> Parameter.Value.Builder<T> choices(@NonNull Class<T> returnType, @NonNull Map<String, ? extends T> choices) Creates a builder that has aValueParameterthat allows you to specify a set of choices that must be chosen from. These choices map to objects that will get put in theCommandContextwhen a choice is selected.- Type Parameters:
T- The type of parameter- Parameters:
returnType- The type of object that will be returned by the parser to be built by this builder.choices- The choices- Returns:
- A
Parameter.Value.Builder
-
choices
static <T> Parameter.Value.Builder<T> choices(@NonNull Class<T> returnType, @NonNull Function<String, ? extends T> valueFunction, @NonNull Supplier<? extends Collection<String>> choices) Creates a builder that has aValueParameterthat allows you to specify a set of choices that must be chosen from. These choices map to objects that will get put in theCommandContextwhen a choice is selected, through the use of thevalueFunction.- Type Parameters:
T- The type of parameter- Parameters:
returnType- The type of object that will be returned by the parser to be built by this builder.valueFunction- The function that returns an object to put in theCommandContextbased on the supplied choicechoices- The choices- Returns:
- A
Parameter.Value.Builder
-
enumValue
Creates a builder that has aValueParameterthat requires an argument that matches the name of a suppliedEnumtype- Type Parameters:
T- The type ofEnum- Parameters:
enumClass- TheEnumclass type- Returns:
- A
Parameter.Value.Builder
-
literal
static <T> Parameter.Value.Builder<T> literal(@NonNull Class<T> returnType, @NonNull T returnedValue, String @NonNull ... literal) Creates a builder that has aValueParameterthat requires an argument to be a literal specified- Type Parameters:
T- The type of value- Parameters:
returnType- The type of object that will be returned by the parser to be built by this builder.returnedValue- The object to put in theCommandContextif the literal matches.literal- The literal to match- Returns:
- A
Parameter.Value.Builder
-
literal
static <T> Parameter.Value.Builder<T> literal(@NonNull Class<T> returnType, @NonNull T returnedValue, @NonNull Supplier<? extends Collection<String>> literalSupplier) Creates a builder that has aValueParameterthat requires an argument to be a literal specified- Type Parameters:
T- The type of parameter- Parameters:
returnedValue- The object to put in theCommandContextif the literal matchesliteralSupplier- A function that provies the literal to match at invocationreturnType- The type of return- Returns:
- A
Parameter.Value.Builder
-
isOptional
boolean isOptional()Gets whether this parameter is optional.An optional parameter will not throw an exception if it cannot parse an input, instead passing control to another parameter.
- Returns:
- true if optional, else false.
-
isTerminal
boolean isTerminal()Gets whether this parameter is known to be able to be explicitly considered a terminal parameter without regarding its place in a command.A terminal parameter will pass control to the command's associated
CommandExecutorif the parameter consumes the end of an input string.Because this parameter may be reused across multiple commands, there may be some circumstances where this parameter will act as a terminal parameter but this is false, such as when this is at the end of a parameter chain or the following parameters are all optional. The return value from this method generally will return whether this element is terminal without regard to other parameters in a command.
- Returns:
- true if known to be terminal.
-