com.github.skjolber.stcsv.databinder.column.bi.CsvFieldMapperBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of databinder Show documentation
Show all versions of databinder Show documentation
High-performance CSV databinding library
package com.github.skjolber.stcsv.databinder.column.bi;
import com.github.skjolber.stcsv.builder.CsvBuilderException;
import com.github.skjolber.stcsv.databinder.builder.AbstractCsvFieldMapperBuilder;
import com.github.skjolber.stcsv.databinder.builder.AbstractCsvMappingBuilder;
import com.github.skjolber.stcsv.databinder.builder.AbstractTypedCsvFieldMapperBuilder;
import com.github.skjolber.stcsv.databinder.builder.SetterProjectionHelper;
import com.github.skjolber.stcsv.databinder.projection.BiConsumerProjection;
import com.github.skjolber.stcsv.databinder.projection.ValueProjection;
public class CsvFieldMapperBuilder> extends AbstractCsvFieldMapperBuilder {
protected CsvColumnValueConsumer consumer;
public CsvFieldMapperBuilder(D parent, String name) {
super(parent, name);
}
public CsvFieldMapperBuilder consumer(CsvColumnValueConsumer consumer) {
this.consumer = consumer;
return this;
}
public CsvFieldMapperBuilder fixedSize(int fixedSize) {
super.fixedSize(fixedSize);
return this;
}
/**
* Indicate that this field is quoted. If there is no linebreaks,
* rather use the method {@linkplain #quotedWithoutLinebreaks()} to improve performance.
*
* @return this instance.
*/
public CsvFieldMapperBuilder quoted() {
super.quoted();
return this;
}
/**
* Indicate that this field is quoted, but has no linebreaks.
*
* @return this instance.
*/
public CsvFieldMapperBuilder quotedWithoutLinebreaks() {
super.quotedWithoutLinebreaks();
return this;
}
public CsvFieldMapperBuilder trimTrailingWhitespaces() {
super.trimTrailingWhitespaces();
return this;
}
public CsvFieldMapperBuilder trimLeadingWhitespaces() {
super.trimLeadingWhitespaces();
return this;
}
protected ValueProjection getProjection(int index, SetterProjectionHelper proxy) throws CsvBuilderException {
if(consumer != null) {
return new BiConsumerProjection(consumer, index);
}
throw new CsvBuilderException("Expected consumer for untyped field '" + name + "'");
}
}