Class CompositeParser<T>

  • All Implemented Interfaces:
    Parser<T>

    public final class CompositeParser<T>
    extends Object
    implements Parser<T>
    A Parser that invokes a list of converters, returning the first converter that was successful. This is created using firstTry(Parser) and new converters are added via thenTry(Parser).
    • Method Detail

      • firstTry

        public static <T,​U> CompositeParser<U> firstTry​(Parser<T> parser,
                                                              Function<T,​U> resultConverter)
        Create a CompositeParser that tries the provided parser first, converting the result of that parser using the provided function.
      • thenTry

        public <S> CompositeParser<T> thenTry​(Parser<S> nextParser,
                                              Function<S,​T> resultConverter)
        Create a new CompositeParser that tries the provided parser after all previous parsers, converting the result of that parser using the provided function.
      • parse

        public ParseResult<T> parse​(int startPosition,
                                    int endPosition)
        Description copied from interface: Parser
        Parse a JMESPath string between the start position (inclusive) and end position (exclusive).
        Specified by:
        parse in interface Parser<T>