- Type Parameters:
T
- The type of argument that is provided.R
- The type of raw argument that is received.
- All Superinterfaces:
BiFunction<CommandContext,
R, Mono<T>>
- All Known Subinterfaces:
ArgumentParser<R,
,T> AttachmentDataParser<T>
,AttachmentParser<T>
,BooleanParser<T>
,ChannelArgumentParser<C,
,T> ChoicesParser<P,
,T> EntityArgumentParser<E,
,T> FloatParser<T>
,FunctorUrlParser<T>
,InputParser<P,
,T> IntegerParser<T>
,ListParser<T>
,MessageArgumentParser<T>
,NumberParser<P,
,T> Parsers.Functor<R,
,T> Parsers.Simple<R,
,T> Parsers.Synchronous<R,
,T> RoleArgumentParser<T>
,SnowflakeParser<T>
,StringParser<T>
,TextFileParser<T>
,TryParser<R,
,T> UrlParser<T>
,UserArgumentParser<T>
- All Known Implementing Classes:
ChannelParser
,ChannelUrlParser
,EntityParser
,EntityUrlParser
,FunctorUrlParser.Choice
,FunctorUrlParser.ChoiceBase
,FunctorUrlParser.PostParser
,MentionableParser
,MessageParser
,MessageUrlParser
,ParserFunction.PostParser
,RoleParser
,StringAdapter
,UrlParser.Choice
,UrlParser.ChoiceBase
,UrlParser.PostParser
,UserParser
public interface ParserFunction<R extends @NonNull Object,T extends @NonNull Object>
extends BiFunction<CommandContext,R,Mono<T>>
A function that parses a value within the context of an execution.
- Since:
- 1.0
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
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>> A composed parser that first applies this parser to one parser, and then applies the results to a second parser. -
Method Summary
Modifier and TypeMethodDescriptionapply
(CommandContext context, R raw) parse
(CommandContext context, R raw) Parses the given raw argument from the user into the corresponding value.default <V extends @NonNull Object>
ParserFunction<R,V> then
(ParserFunction<T, V> after) Returns a composed parser that first applies this parser to its input, and then applies the after parser to the result.Methods inherited from interface java.util.function.BiFunction
andThen
-
Method Details
-
parse
Parses the given raw argument from the user into the corresponding value.- Parameters:
context
- The execution context.raw
- The raw argument received from the user.- Returns:
- A Mono that issues the parsed argument. If the raw value is invalid, it may
fail with a
InvalidArgumentException
. May be empty, in which case the value defers to thedefault
(functionally the same as if the argument was missing, but without causing an error if the parameter isrequired
). - Throws:
InvalidArgumentException
- if the given argument is not a valid value.
-
apply
- Specified by:
apply
in interfaceBiFunction<CommandContext,
R extends @NonNull Object, Mono<T extends @NonNull Object>> - Throws:
InvalidArgumentException
- Implementation Requirements:
- Alias for
parse(CommandContext, Object)
.
-
then
@SideEffectFree default <V extends @NonNull Object> ParserFunction<R,V> then(ParserFunction<T, V> after) Returns a composed parser that first applies this parser to its input, and then applies the after parser to the result. If parsing with either parser throws an exception, it is relayed to the caller of the composed parser.- Type Parameters:
V
- The type of output of theafter
parser, and of the composed parser.- Parameters:
after
- The parser to apply after this parser is applied.- Returns:
- The composed parser.
-