Class ListParser<E>
java.lang.Object
dev.prozilla.pine.common.util.parser.Parser<List<E>>
dev.prozilla.pine.common.util.parser.ListParser<E>
- Type Parameters:
E- The type of elements in the result
- All Implemented Interfaces:
Printable
Parser that parses a list of elements using another parser.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumPolicy that determines how elements are handled when they can't be parsed successfully. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ListParser.ElementParsingFailPolicystatic final StringParser used to parse elements of a list.protected ListParser.ElementParsingFailPolicyThe policy that determines how input elements are handled that theelementParserfails to parse.protected StringThe symbol that separates elements in an input string.Fields inherited from class dev.prozilla.pine.common.util.parser.Parser
GENERIC_ERROR, UNEXPECTED_END_OF_INPUT_ERROR -
Constructor Summary
ConstructorsConstructorDescriptionListParser(Parser<E> elementParser) ListParser(Parser<E> elementParser, String separator) ListParser(Parser<E> elementParser, String separator, ListParser.ElementParsingFailPolicy policy) -
Method Summary
Modifier and TypeMethodDescriptionCreates the initial list used to compose the parsing result.protected StringgetRegex()Returns the regex based on the separator of this parser.booleanParses a string.voidsetElementParser(Parser<E> elementParser) voidvoidsetSeparator(String separator) Methods inherited from class dev.prozilla.pine.common.util.parser.Parser
fail, fail, getError, getResult, parseProperty, read, succeed, toString
-
Field Details
-
elementParser
Parser used to parse elements of a list. -
separator
The symbol that separates elements in an input string. -
policy
The policy that determines how input elements are handled that theelementParserfails to parse. -
DEFAULT_SEPARATOR
- See Also:
-
DEFAULT_POLICY
-
-
Constructor Details
-
ListParser
-
ListParser
-
ListParser
public ListParser(Parser<E> elementParser, String separator, ListParser.ElementParsingFailPolicy policy)
-
-
Method Details
-
parse
Description copied from class:ParserParses a string. -
createList
Creates the initial list used to compose the parsing result.- Returns:
- The initial list
-
getRegex
Returns the regex based on the separator of this parser.- Returns:
- The regex based on the separator
-
setElementParser
-
setSeparator
-
setPolicy
-