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.Subcommand
s can be placed anywhere in a parameter chain where aParameter
can be added, if successfully parsed, any containingCommand
would take precedence and itsCommand.process(CommandCause, ArgumentReader.Mutable)
method will be called instead of any parent.
Parameter
s are intended for use with Command.Builder
s.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Contains methods to create the generic builders.static interface
Specifies a builder for creating aParameter
that returns a parameter that concatenates all parameters into a single parameter to be executed one by one.static interface
static interface
A parameter that consists of multiple parametersstatic interface
Specifies a builder for creating aParameter
that returns a parameter that concatenates all parameters into a single parameter to be executed one by one.static interface
AParameter.Subcommand
represents a literal argument where, if parsed, should indicate to the command processor that theCommandExecutor
of the command should change.static interface
Represents aParameter
that 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 theValueParameter
set toResourceKeyedValueParameters.BIG_DECIMAL
.static Parameter.Value.Builder<BigInteger>
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.BIG_INTEGER
.static Parameter.Value.Builder<BlockState>
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.BLOCK_STATE
.static Parameter.Value.Builder<Boolean>
bool()
Creates a builder that has theValueParameter
set 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 aValueParameter
that allows you to specify a set of choices that must be chosen from.static <T> Parameter.Value.Builder<T>
Creates a builder that has aValueParameter
that allows you to specify a set of choices that must be chosen from.static Parameter.Value.Builder<String>
Creates a builder that has aValueParameter
that allows you to specify a set of choices that must be chosen fromstatic Parameter.Value.Builder<Color>
color()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.COLOR
.static Parameter.Value.Builder<DataContainer>
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DATA_CONTAINER
.static Parameter.Value.Builder<LocalDateTime>
dateTime()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DATE_TIME
.static Parameter.Value.Builder<Double>
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DOUBLE
.static Parameter.Value.Builder<Duration>
duration()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DURATION
.static Parameter.Value.Builder<Entity>
entity()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.ENTITY
.static Parameter.Value.Builder<Entity>
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.ENTITY
static <T extends Enum<T>>
Parameter.Value.Builder<T>Creates a builder that has aValueParameter
that requires an argument that matches the name of a suppliedEnum
typestatic Parameter
Returns aParameter
that attempts to parse an argument using the supplied parameters in order.static Parameter
Returns aParameter
that attempts to parse an argument using the supplied parameters in order.static Parameter.FirstOfBuilder
firstOfBuilder
(@NonNull Parameter parameter) Returns aParameter.FirstOfBuilder
that allows plugins to attempt to parse an argument using the supplied parameters in order.static Parameter.Value.Builder<Component>
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_FORMATTING_CODE
.static Parameter.Value.Builder<Component>
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_FORMATTING_CODE_ALL
.static Parameter.Value.Builder<Integer>
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.INTEGER
.static Parameter.Value.Builder<InetAddress>
ip()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.IP
.boolean
Gets whether this parameter is optional.boolean
Gets 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 theValueParameter
set toResourceKeyedValueParameters.ITEM_STACK_SNAPSHOT
.static Parameter.Value.Builder<Component>
jsonText()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_JSON
.static Parameter.Value.Builder<Component>
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_JSON_ALL
.static <T> Parameter.Key<T>
Creates aParameter.Key
for storing values against.static <T> Parameter.Key<T>
Creates aParameter.Key
for 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 aValueParameter
that requires an argument to be a literal specifiedstatic <T> Parameter.Value.Builder<T>
Creates a builder that has aValueParameter
that requires an argument to be a literal specifiedlocation()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.LOCATION
.static Parameter.Value.Builder<Long>
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.LONG
.static Parameter.Value.Builder<Operator>
operator()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.OPERATOR
.static Parameter.Value.Builder<ServerPlayer>
player()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.PLAYER
.static Parameter.Value.Builder<ServerPlayer>
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.PLAYER
, else the targetstatic Parameter.Value.Builder<org.spongepowered.plugin.PluginContainer>
plugin()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.PLUGIN
.static Parameter.Value.Builder<Double>
rangedDouble
(double min, double max) Creates a builder that has theValueParameter
set toVariableValueParameters.doubleRange()
, using the specified bounds (inclusive).static Parameter.Value.Builder<Integer>
rangedInteger
(int min, int max) Creates a builder that has theValueParameter
set 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 theValueParameter
that 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 theValueParameter
that 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 theValueParameter
that allows you to choose from types registered in a givenRegistry
.static Parameter.Value.Builder<String>
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.REMAINING_JOINED_STRINGS
.static Parameter.Value.Builder<ResourceKey>
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.RESOURCE_KEY
.static Parameter.Value.Builder<Vector3d>
rotation()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.ROTATION
.static Parameter
Returns aParameter
that parses arguments using the supplied parameters in order.static Parameter
Returns aParameter
that parses arguments using the supplied parameters in order.static Parameter.SequenceBuilder
seqBuilder
(@NonNull Parameter parameter) Returns aParameter.SequenceBuilder
that parses arguments using the supplied parameters in order.static Parameter.Value.Builder<String>
string()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.STRING
.static Parameter.Subcommand
subcommand
(@NonNull Command.Parameterized subcommand, @NonNull String alias, String @NonNull ... aliases) Gets aParameter
that represents a subcommand.static Parameter.Value.Builder<URL>
url()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.URL
.static Parameter.Value.Builder<UUID>
user()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.USER
.static Parameter.Value.Builder<UUID>
uuid()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.UUID
.static Parameter.Value.Builder<Vector3d>
vector3d()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.VECTOR3D
.static Parameter.Value.Builder<ServerWorld>
world()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.WORLD
.
-
Method Details
-
key
static <T> Parameter.Key<T> key(@NonNull String key, @NonNull io.leangen.geantyref.TypeToken<T> typeToken) Creates aParameter.Key
for 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.Key
for 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 aClass
parameter
- 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 aTypeToken
parameter
- 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
- TheValueParameter
to 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
- TheValueParameter
to 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 aParameter
that represents a subcommand.If a
Parameter.Subcommand
alias 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
- TheCommand
to executealias
- The first alias of the subcommandaliases
- Subsequent aliases, if any- Returns:
- The
Parameter.Subcommand
for use in aParameter
chain
-
firstOfBuilder
Returns aParameter.FirstOfBuilder
that 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.FirstOfBuilder
to continue chaining
-
firstOf
static Parameter firstOf(@NonNull Parameter first, @NonNull Parameter second, Parameter @NonNull ... parameters) Returns aParameter
that 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 aParameter
that 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.SequenceBuilder
that parses arguments using the supplied parameters in order.- Parameters:
parameter
- The firstParameter
in 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 aParameter
that parses arguments using the supplied parameters in order. -
seq
Returns aParameter
that parses arguments using the supplied parameters in order. -
bigDecimal
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.BIG_DECIMAL
.- Returns:
- A
Parameter.Value.Builder
-
bigInteger
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.BIG_INTEGER
.- Returns:
- A
Parameter.Value.Builder
-
blockState
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.BLOCK_STATE
.- Returns:
- A
Parameter.Value.Builder
-
bool
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.BOOLEAN
.- Returns:
- A
Parameter.Value.Builder
-
color
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.COLOR
.- Returns:
- A
Parameter.Value.Builder
-
dataContainer
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DATA_CONTAINER
.- Returns:
- A
Parameter.Value.Builder
-
dateTime
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DATE_TIME
.- Returns:
- A
Parameter.Value.Builder
-
duration
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DURATION
.- Returns:
- A
Parameter.Value.Builder
-
doubleNumber
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DOUBLE
.- Returns:
- A
Parameter.Value.Builder
-
entity
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.ENTITY
.- Returns:
- A
Parameter.Value.Builder
-
entityOrTarget
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.ENTITY
- Returns:
- A
Parameter.Value.Builder
-
formattingCodeText
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_FORMATTING_CODE
.- Returns:
- A
Parameter.Value.Builder
-
formattingCodeTextOfRemainingElements
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_FORMATTING_CODE_ALL
.- Returns:
- A
Parameter.Value.Builder
-
integerNumber
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.INTEGER
.- Returns:
- A
Parameter.Value.Builder
-
ip
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.IP
.- Returns:
- A
Parameter.Value.Builder
-
itemStackSnapshot
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.ITEM_STACK_SNAPSHOT
.- Returns:
- A
Parameter.Value.Builder
-
jsonText
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_JSON
.- Returns:
- A
Parameter.Value.Builder
-
jsonTextOfRemainingElements
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_JSON_ALL
.- Returns:
- A
Parameter.Value.Builder
-
location
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.LOCATION
.- Returns:
- A
Parameter.Value.Builder
-
longNumber
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.LONG
.- Returns:
- A
Parameter.Value.Builder
-
operator
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.OPERATOR
.- Returns:
- A
Parameter.Value.Builder
-
player
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.PLAYER
.- Returns:
- A
Parameter.Value.Builder
-
playerOrTarget
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.PLAYER
, else the target- Returns:
- A
Parameter.Value.Builder
-
plugin
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.PLUGIN
.- Returns:
- A
Parameter.Value.Builder
-
rangedDouble
Creates a builder that has theValueParameter
set 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 theValueParameter
set 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 theValueParameter
set toResourceKeyedValueParameters.REMAINING_JOINED_STRINGS
.- Returns:
- A
Parameter.Value.Builder
-
resourceKey
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.RESOURCE_KEY
.- Returns:
- A
Parameter.Value.Builder
-
rotation
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.ROTATION
.- Returns:
- A
Parameter.Value.Builder
-
string
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.STRING
.- Returns:
- A
Parameter.Value.Builder
-
url
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.URL
.- Returns:
- A
Parameter.Value.Builder
-
user
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.USER
.- Returns:
- A
Parameter.Value.Builder
-
uuid
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.UUID
.- Returns:
- A
Parameter.Value.Builder
-
vector3d
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.VECTOR3D
.- Returns:
- A
Parameter.Value.Builder
-
world
Creates a builder that has theValueParameter
set 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 theValueParameter
that allows you to choose from cataloged types.See
#defaultNamespace(String)
for how default namespaces work.If the
Game
orServer
scopedRegistryHolder
is required,VariableValueParameters.RegistryEntryBuilder.GLOBAL_HOLDER_PROVIDER
orVariableValueParameters.RegistryEntryBuilder.SERVER_HOLDER_PROVIDER
may be used.- Type Parameters:
T
- The type of registry value- Parameters:
type
- The registry value type to check for choicesholderProvider
- AFunction
that provides the appropriateRegistryHolder
to get the appropriateRegistry
registryKey
- TheRegistryKey
that represents the targetRegistry
defaultNamespaces
- 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 theValueParameter
that allows you to choose from cataloged types.See
#defaultNamespace(String)
for how default namespaces work.If the
Game
orServer
scopedRegistryHolder
is required,VariableValueParameters.RegistryEntryBuilder.GLOBAL_HOLDER_PROVIDER
orVariableValueParameters.RegistryEntryBuilder.SERVER_HOLDER_PROVIDER
may be used.- Type Parameters:
T
- The type of registry value- Parameters:
type
- The registry value type to check for choicesholderProviders
-Function
s that provides the appropriateRegistryHolder
to get the appropriateRegistry
registryKey
- TheRegistryKey
that represents the targetRegistry
defaultNamespaces
- 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 theValueParameter
that 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
- TheDefaultedRegistryType
to 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 aValueParameter
that allows you to specify a set of choices that must be chosen fromThis will return a parser that will return
String
s- 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 aValueParameter
that allows you to specify a set of choices that must be chosen from. These choices map to objects that will get put in theCommandContext
when 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 aValueParameter
that allows you to specify a set of choices that must be chosen from. These choices map to objects that will get put in theCommandContext
when 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 theCommandContext
based on the supplied choicechoices
- The choices- Returns:
- A
Parameter.Value.Builder
-
enumValue
Creates a builder that has aValueParameter
that requires an argument that matches the name of a suppliedEnum
type- Type Parameters:
T
- The type ofEnum
- Parameters:
enumClass
- TheEnum
class 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 aValueParameter
that 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 theCommandContext
if 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 aValueParameter
that requires an argument to be a literal specified- Type Parameters:
T
- The type of parameter- Parameters:
returnedValue
- The object to put in theCommandContext
if 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
CommandExecutor
if 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.
-