- Type Parameters:
T
- The type of argument that is provided.
- All Superinterfaces:
ArgumentParser<String,
,T> BiFunction<CommandContext,
,String, Mono<T>> ChoicesParser<String,
,T> InputParser<String,
,T> ParserFunction<String,
T>
- All Known Subinterfaces:
ListParser<T>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
- Since:
- 1.0
- Version:
- 1.0
- API Note:
- Implementations do not have to verify in parsing that the length of the received raw
value is within the range specified by
minLength()
andmaxLength()
. The system will automatically do this verification before invoking the parser.
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.ChoicesParser
ChoicesParser.Choice<P extends @NonNull Object>
Nested classes/interfaces inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.ParserFunction
ParserFunction.PostParser<R extends @NonNull Object,
I extends @NonNull Object, T extends @NonNull Object, P1 extends @NonNull ParserFunction<R, I>, P2 extends @NonNull ParserFunction<I, T>> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The maximum length possible (in the Discord API for application commands).Fields inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.ChoicesParser
MAX_CHOICES
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
Whether to allow merge behavior when a parameter using this parser is the last parameter of the command.The maximum length allowed (inclusive).The minimum length allowed (inclusive).default String
validateRaw
(String raw) Validates the raw value before parsing.default String
verifyLength
(String raw) Verifies that the given string is within the allowed length range for this parser.Methods inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.ArgumentParser
parse, parseArgument
Methods inherited from interface java.util.function.BiFunction
andThen
Methods inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.ChoicesParser
choices, verifyChoice
Methods inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.ParserFunction
apply, then
-
Field Details
-
MAX_LENGTH
static final int MAX_LENGTHThe maximum length possible (in the Discord API for application commands).- See Also:
-
-
Method Details
-
minLength
The minimum length allowed (inclusive).- Returns:
- The length, or
null
if no minimum. - Implementation Requirements:
- The default is
null
. Must be between 0 and 6000.
-
maxLength
The maximum length allowed (inclusive).- Returns:
- The length, or
null
if no maximum. - Implementation Requirements:
- The default is
null
. Must be between 1 and 6000.
-
allowMerge
Whether to allow merge behavior when a parameter using this parser is the last parameter of the command.If enabled, whenever an associated parameter is the last parameter of a message-based invocation, all content in the message beyond the second-to-last argument is considered to correspond to this parameter, and is parsed as-is, rather than being tokenized like the preceding arguments.
This behavior allows the last argument to contain delimiter characters (such as spaces) and generally maintain formatting without the user needing to surround it with quotes (particularly useful when the last parameter is a message or a list).
One consequence of it, however, is that if the user does include quotes (out of habit, for example), they will not be stripped prior to parsing. It also disables automatic checking for extra arguments, which may cause parsing errors instead.
If this parameter is not the last parameter, or the invocation is not through a message, this value is ignored.
- Returns:
- Whether to enable merge behavior.
- Implementation Requirements:
- The default is
false
.
-
verifyLength
Verifies that the given string is within the allowed length range for this parser.- Parameters:
raw
- The string to validate.- Returns:
- The given string.
- Throws:
InvalidArgumentException
- If the length is outside the allowed range.- API Note:
- Implementations do not need to call this method.
-
validateRaw
Description copied from interface:ArgumentParser
Validates the raw value before parsing.- Specified by:
validateRaw
in interfaceArgumentParser<String,
T extends @NonNull Object> - Specified by:
validateRaw
in interfaceChoicesParser<String,
T extends @NonNull Object> - Parameters:
raw
- The raw value.- Returns:
- The raw value.
- Throws:
InvalidArgumentException
- if the value is invalid.
-