Class ExporterBuilder<O>

java.lang.Object
org.nuiton.csv.ExporterBuilder<O>

public class ExporterBuilder<O> extends Object
To build an Exporter. Created on 09/12/15.
Since:
3.0
Author:
Tony Chemit - chemit@codelutin.com
  • Field Details

  • Constructor Details

    • ExporterBuilder

      public ExporterBuilder()
    • ExporterBuilder

      public ExporterBuilder(ExporterConfiguration<O> configuration)
  • Method Details

    • setCellSeparator

      public ExporterBuilder<O> setCellSeparator(String cellSeparator)
      Set the ExporterConfiguration.cellSeparator and return the builder.
      Parameters:
      cellSeparator - new value for ExporterConfiguration.cellSeparator.
      Returns:
      the builder
    • setEndOfLineSeparator

      public ExporterBuilder<O> setEndOfLineSeparator(String endOfLineSeparator)
      Set the ExporterConfiguration.endOfLineSeparator and return the builder.
      Parameters:
      endOfLineSeparator - new value for ExporterConfiguration.endOfLineSeparator.
      Returns:
      the builder
    • setCharset

      public ExporterBuilder<O> setCharset(Charset charset)
      Set the ExporterConfiguration.charset and return the builder.
      Parameters:
      charset - new value for ExporterConfiguration.charset.
      Returns:
      the builder
    • addColumns

      public ExporterBuilder<O> addColumns(Iterable<ExportableColumn<O,Object>> columns)
      Add the given columns.
      Parameters:
      columns - columns to add to the builder
      Returns:
      the builder
    • addColumn

      public ExporterBuilder<O> addColumn(String propertyName)
      Add a new column for the given property name, using also the property name as the export header name. The property is exported using a String formatted.
      Parameters:
      propertyName - the property name to export
      Returns:
      the builder
    • addColumn

      public ExporterBuilder<O> addColumn(String headerName, String propertyName)
      Add a new column for the given property name and export as the given header name. The property is obtained using a simple getter and exported using a String formatter.
      Parameters:
      headerName - the header name to use in export
      propertyName - the property name to export
      Returns:
      the builder
    • addColumn

      public ExporterBuilder<O> addColumn(String headerName, ValueGetter<O,String> valueGetter)
      Add a new column for the given property name and export as the given header name. The property is obtained using the given value getter and exported using a String formatter.
      Parameters:
      headerName - the header name to use in export
      valueGetter - the value getter
      Returns:
      the builder
    • addColumn

      public <T> ExporterBuilder<O> addColumn(String headerName, String propertyName, ValueFormatter<T> valueFormatter)
      Add a new column for the given property name and export as the given header name. The property is obtained using a simple getter and exported using the given value formatter.
      Parameters:
      headerName - the header name to use in export
      propertyName - the property name to export
      valueFormatter - the value formatter
      Returns:
      the builder
    • addColumn

      public <T> ExporterBuilder<O> addColumn(String headerName, ValueGetter<O,T> valueGetter, ValueFormatter<T> valueFormatter)
      Add a new column for the given property name and exported as the given header name. The property is obtained using the value getter and exported using the given value formatter.
      Parameters:
      headerName - the header name to use in export
      valueGetter - the value getter
      valueFormatter - the value formatter
      Returns:
      the builder
    • build

      public Exporter<O> build()