public final class CompositeParser<T> extends Object implements Parser<T>
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)
.Modifier and Type | Method and Description |
---|---|
static <T> CompositeParser<T> |
firstTry(Parser<T> parser)
Create a
CompositeParser that tries the provided parser first. |
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. |
ParseResult<T> |
parse(int startPosition,
int endPosition)
Parse a JMESPath string between the start position (inclusive) and end position (exclusive).
|
<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. |
CompositeParser<T> |
thenTry(Parser<T> nextParser)
Create a new
CompositeParser that tries the provided parser after all previous parsers. |
public static <T> CompositeParser<T> firstTry(Parser<T> parser)
CompositeParser
that tries the provided parser first.public static <T,U> CompositeParser<U> firstTry(Parser<T> parser, Function<T,U> resultConverter)
CompositeParser
that tries the provided parser first, converting the result of that parser using the
provided function.public CompositeParser<T> thenTry(Parser<T> nextParser)
CompositeParser
that tries the provided parser after all previous parsers.public <S> CompositeParser<T> thenTry(Parser<S> nextParser, Function<S,T> resultConverter)
CompositeParser
that tries the provided parser after all previous parsers, converting the result of
that parser using the provided function.Copyright © 2022. All rights reserved.