Class ExporterBuilder<O>
java.lang.Object
org.nuiton.csv.ExporterBuilder<O>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.google.common.collect.ImmutableSet.Builder<ExportableColumn<O, ?>> protected final ExporterConfiguration<O> static final Stringstatic final Charsetstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd a new column for the given property name, using also the property name as the export header name.Add a new column for the given property name and export as the given header name.<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.addColumn(String headerName, ValueGetter<O, String> valueGetter) Add a new column for the given property name and export as the given header name.<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.addColumns(Iterable<ExportableColumn<O, Object>> columns) Add the given columns.build()setCellSeparator(String cellSeparator) Set theExporterConfiguration.cellSeparatorand return the builder.setCharset(Charset charset) Set theExporterConfiguration.charsetand return the builder.setEndOfLineSeparator(String endOfLineSeparator) Set theExporterConfiguration.endOfLineSeparatorand return the builder.
-
Field Details
-
DEFAULT_CELL_SEPARATOR
- See Also:
-
DEFAULT_END_OF_LINE_SEPARATOR
- See Also:
-
DEFAULT_CHARSET
-
configuration
-
columnsBuilder
protected final com.google.common.collect.ImmutableSet.Builder<ExportableColumn<O,?>> columnsBuilder
-
-
Constructor Details
-
ExporterBuilder
public ExporterBuilder() -
ExporterBuilder
-
-
Method Details
-
setCellSeparator
Set theExporterConfiguration.cellSeparatorand return the builder.- Parameters:
cellSeparator- new value forExporterConfiguration.cellSeparator.- Returns:
- the builder
-
setEndOfLineSeparator
Set theExporterConfiguration.endOfLineSeparatorand return the builder.- Parameters:
endOfLineSeparator- new value forExporterConfiguration.endOfLineSeparator.- Returns:
- the builder
-
setCharset
Set theExporterConfiguration.charsetand return the builder.- Parameters:
charset- new value forExporterConfiguration.charset.- Returns:
- the builder
-
addColumns
Add the given columns.- Parameters:
columns- columns to add to the builder- Returns:
- the builder
-
addColumn
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
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 exportpropertyName- the property name to export- Returns:
- the builder
-
addColumn
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 exportvalueGetter- 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 exportpropertyName- the property name to exportvalueFormatter- 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 exportvalueGetter- the value gettervalueFormatter- the value formatter- Returns:
- the builder
-
build
-