- Type Parameters:
R
- The raw type.
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface RawParser<R extends @NonNull Object>
extends Function<String,Mono<R>>
Parser function that converts a string into one of the supported raw types.
- Since:
- 1.0
- Version:
- 1.0
- API Note:
- You would normally never need to manually implement this, as this interface already provides parsers for all the supported types through constants and static methods.
-
Field Summary
Modifier and TypeFieldDescriptionParser for booleans.Parser for floats.Parser for integers.Parser for snowflakes.Parser for strings. -
Method Summary
Modifier and TypeMethodDescriptionchannel
(CommandContext context, Class<C> type) Creates a parser for channels with the given context.channelId
(CommandContext context) Creates a parser for channel IDs with the given context.message
(CommandContext context) Creates a parser for messages with the given context.messageId
(CommandContext context) Creates a parser for message IDs with the given context.Parses the given string into a raw value.role
(CommandContext context) Creates a parser for roles with the given context.roleId
(CommandContext context) Creates a parser for role IDs with the given context.user
(CommandContext context) Creates a parser for users with the given context.userId
(CommandContext context) Creates a parser for user IDs with the given context.
-
Field Details
-
STRING
Parser for strings.- API Note:
- This is a trivial parser, but it exists for consistency reasons.
-
BOOLEAN
Parser for booleans. -
INTEGER
Parser for integers. -
FLOAT
Parser for floats. -
SNOWFLAKE
Parser for snowflakes.
-
-
Method Details
-
message
Creates a parser for messages with the given context.- Parameters:
context
- The context to use.- Returns:
- The parser.
-
user
Creates a parser for users with the given context.- Parameters:
context
- The context to use.- Returns:
- The parser.
-
role
Creates a parser for roles with the given context.- Parameters:
context
- The context to use.- Returns:
- The parser.
-
channel
@SideEffectFree static <C extends @NonNull Channel> RawParser<C> channel(CommandContext context, Class<C> type) Creates a parser for channels with the given context.- Type Parameters:
C
- The channel type.- Parameters:
context
- The context to use.type
- The channel type.- Returns:
- The parser.
-
messageId
Creates a parser for message IDs with the given context.- Parameters:
context
- The context to use.- Returns:
- The parser.
-
userId
Creates a parser for user IDs with the given context.- Parameters:
context
- The context to use.- Returns:
- The parser.
-
roleId
Creates a parser for role IDs with the given context.- Parameters:
context
- The context to use.- Returns:
- The parser.
-
channelId
Creates a parser for channel IDs with the given context.- Parameters:
context
- The context to use.- Returns:
- The parser.
-
parse
Parses the given string into a raw value.- Parameters:
raw
- The original string.- Returns:
- The pre-parsed raw value. May fail with a
InvalidArgumentException
if the received value is invalid.
-
apply
-