java.lang.Object
dev.sympho.modular_commands.utils.parse.entity.EntityParser<E>
- Type Parameters:
E- The entity type.
- All Implemented Interfaces:
ParserFunction<String,,E> BiFunction<CommandContext,String, Mono<E>>
- Direct Known Subclasses:
ChannelParser,MessageParser,RoleParser,UserParser
public abstract class EntityParser<E extends @NonNull Entity>
extends Object
implements ParserFunction<String,E>
A parser that extracts an entity from a 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
ConstructorsModifierConstructorDescriptionprotectedEntityParser(EntityRefParser<? extends EntityRef<E>> parser) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionparse(CommandContext context, String raw) Parses the given raw argument from the user into the corresponding value.Methods 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
-
EntityParser
Creates a new instance.- Parameters:
parser- The parser to delegate to.
-
-
Method Details
-
parse
Description copied from interface:ParserFunctionParses the given raw argument from the user into the corresponding value.- Specified by:
parsein interfaceParserFunction<String,E extends @NonNull Entity> - 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.
-