Class AbstractTemporalAccessorParsingProcessor<T extends TemporalAccessor>

java.lang.Object
org.supercsv.cellprocessor.CellProcessorAdaptor
org.supercsv.cellprocessor.time.AbstractTemporalAccessorParsingProcessor<T>
Type Parameters:
T - the TemporalAccessor type that the processor returns
All Implemented Interfaces:
CellProcessor, StringCellProcessor
Direct Known Subclasses:
ParseLocalDate, ParseLocalDateTime, ParseLocalTime, ParseZonedDateTime

public abstract class AbstractTemporalAccessorParsingProcessor<T extends TemporalAccessor> extends CellProcessorAdaptor implements StringCellProcessor
Abstract base class for cell processors converting Strings to TemporalAccessor types.
Since:
2.4.0
  • Field Details

  • Constructor Details

    • AbstractTemporalAccessorParsingProcessor

      public AbstractTemporalAccessorParsingProcessor()
      Constructs a new AbstractTemporalAccessorParsingProcessor processor, which parses a String as a TemporalAccessor type.
    • AbstractTemporalAccessorParsingProcessor

      public AbstractTemporalAccessorParsingProcessor(CellProcessor next)
      Constructs a new AbstractTemporalAccessorParsingProcessor processor, which parses a String as a TemporalAccessor type, then calls the next processor in the chain.
      Parameters:
      next - the next processor in the chain
      Throws:
      NullPointerException - if next is null
    • AbstractTemporalAccessorParsingProcessor

      public AbstractTemporalAccessorParsingProcessor(DateTimeFormatter formatter)
      Constructs a new AbstractTemporalAccessorParsingProcessor processor, which parses a String as a TemporalAccessor type using the supplied formatter.
      Parameters:
      formatter - the formatter used for parsing
      Throws:
      NullPointerException - if formatter is null
    • AbstractTemporalAccessorParsingProcessor

      public AbstractTemporalAccessorParsingProcessor(DateTimeFormatter formatter, CellProcessor next)
      Constructs a new AbstractTemporalAccessorParsingProcessor processor, which parses a String as a TemporalAccessor type using the supplied formatter, then calls the next processor in the chain.
      Parameters:
      formatter - the formatter used for parsing
      next - the next processor in the chain
      Throws:
      NullPointerException - if formatter or next is null
  • Method Details

    • checkPreconditions

      private static void checkPreconditions(DateTimeFormatter formatter)
      Checks the preconditions for creating a new AbstractTemporalAccessorParsingProcessor processor.
      Parameters:
      formatter - the formatter
      Throws:
      NullPointerException - if formatter is null
    • execute

      public Object execute(Object value, CsvContext context)
      This method is invoked by the framework when the processor needs to process data or check constraints.
      Specified by:
      execute in interface CellProcessor
      Parameters:
      value - the value to be processed
      context - the CSV context
      Returns:
      the result of cell processor execution
      Throws:
      SuperCsvCellProcessorException - if value is null or is not a String
    • parse

      protected abstract T parse(String string)
      Parses the String into the appropriate TemporalAccessor type.
      Parameters:
      string - the string to parse
      Returns:
      the TemporalAccessor type
      Throws:
      IllegalArgumentException - if the string can't be parsed
    • parse

      protected abstract T parse(String string, DateTimeFormatter formatter)
      Parses the String into the appropriate TemporalAccessor type, using the supplied formatter.
      Parameters:
      string - the string to parse
      formatter - the formatter to use
      Returns:
      the TemporalAccessor type
      Throws:
      IllegalArgumentException - if the string can't be parsed