Class DatevStreamWriter.Builder

java.lang.Object
io.github.mrtyldr.datev.plain.DatevStreamWriter.Builder
Enclosing class:
DatevStreamWriter

public static final class DatevStreamWriter.Builder extends Object
Configures a streaming writer, including the optional EXTF management record.

The static factories cover the common cases; this builder exists so schema, validator and metadata can be combined without a factory per combination. Nothing is written until one of the build methods is called. Instances are not thread-safe.

  • Method Details

    • validator

      public DatevStreamWriter.Builder validator(BiConsumer<Integer,List<String>> validator)
      Sets the optional row validator.
      Parameters:
      validator - receives the format version and each immutable aligned row
      Returns:
      this builder
    • metadata

      public DatevStreamWriter.Builder metadata(io.github.mrtyldr.datev.core.DatevMetadata metadata)
      Sets the EXTF management record written before the heading.
      Parameters:
      metadata - the management record
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the metadata's format version differs from the schema
    • build

      public DatevStreamWriter build(OutputStream output)
      Starts a writer on a caller-owned byte stream, emitting Windows-1252 directly.
      Parameters:
      output - the caller-owned destination stream
      Returns:
      a new writer that has already written its leading records
    • build

      public DatevStreamWriter build(Writer output)
      Starts a writer on a caller-owned character writer.
      Parameters:
      output - the caller-owned destination writer
      Returns:
      a new writer that has already written its leading records