Class RoleRefMentionParser
java.lang.Object
dev.sympho.modular_commands.utils.parse.entity.EntityRefMentionParser<EntityRef.RoleRef>
dev.sympho.modular_commands.utils.parse.entity.RoleRefMentionParser
- All Implemented Interfaces:
ParserFunction<String,,EntityRef.RoleRef> BiFunction<CommandContext,String, Mono<EntityRef.RoleRef>>
A parser for user mentions to references.
Note that this parser does not support @everyone and @here in
EntityRefMentionParser.parseId(String), as they do not have a unique ID. They are, however,
supported by parseRef(CommandContext, String) and
EntityRefMentionParser.parse(CommandContext, String).
- Since:
- 1.0
- Version:
- 1.0
-
Nested Class Summary
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>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected EntityRef.RoleRefmakeRef(CommandContext context, Snowflake id) Creates the reference.parseRef(CommandContext context, String raw) Parses the given string.protected booleanprefixMatches(String prefix) Determines if the mention prefix matches the expected type.protected StringtypeName()Gets the display name for this type.Methods inherited from class dev.sympho.modular_commands.utils.parse.entity.EntityRefMentionParser
parse, parseIdMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.function.BiFunction
andThenMethods inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.ParserFunction
apply, then
-
Constructor Details
-
RoleRefMentionParser
public RoleRefMentionParser()Creates a new instance.
-
-
Method Details
-
prefixMatches
Description copied from class:EntityRefMentionParserDetermines if the mention prefix matches the expected type.- Specified by:
prefixMatchesin classEntityRefMentionParser<EntityRef.RoleRef>- Parameters:
prefix- The detected prefix.- Returns:
trueif the prefix matches the expected,falseotherwise.
-
makeRef
Description copied from class:EntityRefMentionParserCreates the reference.- Specified by:
makeRefin classEntityRefMentionParser<EntityRef.RoleRef>- Parameters:
context- The execution context.id- The parsed ID.- Returns:
- The created reference.
-
typeName
Description copied from class:EntityRefMentionParserGets the display name for this type.- Specified by:
typeNamein classEntityRefMentionParser<EntityRef.RoleRef>- Returns:
- The name.
-
parseRef
public @Nullable EntityRef.RoleRef parseRef(CommandContext context, String raw) throws InvalidArgumentException Description copied from class:EntityRefMentionParserParses the given string.- Overrides:
parseRefin classEntityRefMentionParser<EntityRef.RoleRef>- Parameters:
context- The execution context.raw- The string to parse.- Returns:
- The reference parsed from the mention, or
nullif the given string is not a mention. - Throws:
InvalidArgumentException- if the given string is a mention but of the wrong type.
-