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

public class ListParser<E> extends Parser<List<E>>
Parser that parses a list of elements using another parser.
  • Field Details

  • Constructor Details

  • Method Details

    • parse

      public boolean parse(String input)
      Description copied from class: Parser
      Parses a string.
      Specified by:
      parse in class Parser<List<E>>
      Parameters:
      input - The input string to parse
      Returns:
      true if the parsing succeeded.
    • createList

      protected List<E> createList()
      Creates the initial list used to compose the parsing result.
      Returns:
      The initial list
    • getRegex

      protected String getRegex()
      Returns the regex based on the separator of this parser.
      Returns:
      The regex based on the separator
    • setElementParser

      public void setElementParser(Parser<E> elementParser)
    • setSeparator

      public void setSeparator(String separator)
    • setPolicy

      public void setPolicy(ListParser.ElementParsingFailPolicy policy)