java.lang.Object
dev.sympho.modular_commands.utils.parse.entity.EntityUrlParser<E>
- Type Parameters:
E- The entity type.
- All Implemented Interfaces:
ParserFunction<String,,E> UrlParser<E>,BiFunction<CommandContext,String, Mono<E>>
- Direct Known Subclasses:
ChannelUrlParser,MessageUrlParser
public abstract class EntityUrlParser<E extends @NonNull Entity>
extends Object
implements UrlParser<E>
A parser for URLs of Discord entities.
- Since:
- 1.0
- Version:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.sympho.modular_commands.utils.parse.UrlParser
UrlParser.Choice<T extends @NonNull Object>, UrlParser.ChoiceBase<T extends @NonNull Object,P extends UrlParser<T>>, UrlParser.PostParser<I extends @NonNull Object, T extends @NonNull Object, P1 extends @NonNull UrlParser<I>, P2 extends @NonNull ParserFunction<I, T>> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEntityUrlParser(EntityRefUrlParser<? extends EntityRef<E>> refParser) Creates a new instance. -
Method Summary
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
-
Constructor Details
-
EntityUrlParser
Creates a new instance.- Parameters:
refParser- The parser to obtain the reference with.
-
-
Method Details
-
supports
Description copied from interface:UrlParserChecks if the given URL is supported by this parser. If this returnsfalse, callingUrlParser.parse(CommandContext, URL)with the same URL will result in an error.Note that the opposite isn't necessarily true; it is possible for this method to return
truefor a given URL whileUrlParser.parse(CommandContext, URL)results in an error. That just means that the basic structure of the URL was detected as being compatible with this parser (for example, having a particular host and/or protocol), but was malformed or a variant that the parser doesn't support. -
parse
Description copied from interface:UrlParserParses the given URL.- Specified by:
parsein interfaceUrlParser<E extends @NonNull Entity>- Parameters:
context- The execution context.url- The URL to parse.- Returns:
- The parsed value. May result in a
InvalidArgumentExceptionif the URL is invalid. - Throws:
InvalidArgumentException- if the URL is invalid.
-