Class DetectingParser<T>

  • All Implemented Interfaces:
    BasicParser<T>, TextLineReader.Parser<T>
    Direct Known Subclasses:
    DatePriceParser

    public abstract class DetectingParser<T>
    extends java.lang.Object
    implements BasicParser<T>
    Will detect which delegate parser to use. Must be able to determine that from the first line read. You supply a collection of parsers paired with logic to test if they can handle the proposed line or not.
    See Also:
    DatePriceParser
    • Method Detail

      • parse

        public T parse​(java.lang.String line)
        Description copied from interface: TextLineReader.Parser
        Parse one line into some custom object. Returning null indicates that parsing failed!
        Specified by:
        parse in interface TextLineReader.Parser<T>
        Parameters:
        line - The text line to parse
        Returns:
        An object containing (referencing) the parsed data
      • addPotentialParser

        protected void addPotentialParser​(java.util.function.Predicate<java.lang.String> predicate,
                                          TextLineReader.Parser<? extends T> parser)