Class CompositeParser<T>

java.lang.Object
software.amazon.awssdk.codegen.jmespath.parser.util.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 Details

    • firstTry

      public static <T> CompositeParser<T> firstTry(Parser<T> parser)
      Create a CompositeParser that tries the provided parser first.
    • 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 CompositeParser<T> thenTry(Parser<T> nextParser)
      Create a new CompositeParser that tries the provided parser after all previous parsers.
    • 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>