Class UrlParser.PostParser<I extends @NonNull Object,T extends @NonNull Object,P1 extends @NonNull UrlParser<I>,P2 extends @NonNull ParserFunction<I,T>>

java.lang.Object
dev.sympho.modular_commands.api.command.parameter.parse.ParserFunction.PostParser<String,I,T,P1,P2>
dev.sympho.modular_commands.utils.parse.UrlParser.PostParser<I,T,P1,P2>
Type Parameters:
I - The intermediary type output by the first parser and consumed by the second.
T - The final output type.
P1 - The type of the first parser.
P2 - The type of the second parser.
All Implemented Interfaces:
ParserFunction<String,T>, UrlParser<T>, BiFunction<CommandContext,String,Mono<T>>
Direct Known Subclasses:
FunctorUrlParser.PostParser
Enclosing interface:
UrlParser<T extends @NonNull Object>

public static class UrlParser.PostParser<I extends @NonNull Object,T extends @NonNull Object,P1 extends @NonNull UrlParser<I>,P2 extends @NonNull ParserFunction<I,T>> extends ParserFunction.PostParser<String,I,T,P1,P2> implements UrlParser<T>
A composed parser that first applies this parser to one parser, and then applies the results to a second parser. If parsing with either parser throws an exception, it is relayed to the caller of the composed parser.

Note that compatibility is defined only by the first parser.

Since:
1.0
  • Constructor Details

    • PostParser

      public PostParser(P1 parser, P2 postParser)
      Creates a new instance.
      Parameters:
      parser - The first parser to apply.
      postParser - The second parser to apply.
  • Method Details

    • supports

      public boolean supports(URL url)
      Description copied from interface: UrlParser
      Checks if the given URL is supported by this parser. If this returns false, calling UrlParser.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 true for a given URL while UrlParser.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.

      Specified by:
      supports in interface UrlParser<I extends @NonNull Object>
      Parameters:
      url - The URL to check.
      Returns:
      Whether the URL is compatible with this parser.
    • parse

      public Mono<T> parse(CommandContext context, URL url) throws InvalidArgumentException
      Description copied from interface: UrlParser
      Parses the given URL.
      Specified by:
      parse in interface UrlParser<I extends @NonNull Object>
      Parameters:
      context - The execution context.
      url - The URL to parse.
      Returns:
      The parsed value. May result in a InvalidArgumentException if the URL is invalid.
      Throws:
      InvalidArgumentException - if the URL is invalid.