com.github.skjolber.stcsv.builder.CsvMappingBuilder 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.builder;
import java.util.List;
import com.github.skjolber.stcsv.AbstractColumn;
import com.github.skjolber.stcsv.CsvMapper;
import com.github.skjolber.stcsv.column.bi.BooleanCsvFieldMapperBuilder;
import com.github.skjolber.stcsv.column.bi.CsvFieldMapperBuilder;
import com.github.skjolber.stcsv.column.bi.DoubleCsvFieldMapperBuilder;
import com.github.skjolber.stcsv.column.bi.IntCsvFieldMapperBuilder;
import com.github.skjolber.stcsv.column.bi.LongCsvFieldMapperBuilder;
import com.github.skjolber.stcsv.column.bi.StringCsvFieldMapperBuilder;
public class CsvMappingBuilder extends AbstractCsvMappingBuilder> {
public CsvMappingBuilder(Class cls) {
super(cls);
}
public CsvMapper build() throws CsvBuilderException {
List columns = toColumns();
ClassLoader classLoader = this.classLoader;
if(classLoader == null) {
classLoader = getDefaultClassLoader();
}
if(bufferLength <= 0) {
throw new CsvBuilderException("Expected positive buffer length");
}
return new CsvMapper(target, divider, quoteCharacter, escapeCharacter, columns, skipEmptyLines, skipComments, skippableFieldsWithoutLinebreaks, classLoader, bufferLength);
}
public CsvFieldMapperBuilder> field(String name) {
return new CsvFieldMapperBuilder>(this, name);
}
public StringCsvFieldMapperBuilder> stringField(String name) {
return new StringCsvFieldMapperBuilder>(this, name);
}
public DoubleCsvFieldMapperBuilder> doubleField(String name) {
return new DoubleCsvFieldMapperBuilder>(this, name);
}
public LongCsvFieldMapperBuilder> longField(String name) {
return new LongCsvFieldMapperBuilder>(this, name);
}
public IntCsvFieldMapperBuilder> integerField(String name) {
return new IntCsvFieldMapperBuilder>(this, name);
}
public BooleanCsvFieldMapperBuilder> booleanField(String name) {
return new BooleanCsvFieldMapperBuilder>(this, name);
}
}