All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.skjolber.stcsv.builder.CsvMappingBuilder2 Maven / Gradle / Ivy

There is a newer version: 1.0.25
Show newest version
package com.github.skjolber.stcsv.builder;

import java.util.List;

import com.github.skjolber.stcsv.AbstractColumn;
import com.github.skjolber.stcsv.CsvMapper2;
import com.github.skjolber.stcsv.column.tri.BooleanCsvFieldMapperTriBuilder;
import com.github.skjolber.stcsv.column.tri.CsvFieldMapperTriBuilder;
import com.github.skjolber.stcsv.column.tri.DoubleCsvFieldMapperTriBuilder;
import com.github.skjolber.stcsv.column.tri.IntCsvFieldMapperTriBuilder;
import com.github.skjolber.stcsv.column.tri.LongCsvFieldMapperTriBuilder;
import com.github.skjolber.stcsv.column.tri.StringCsvFieldMapperTriBuilder;

public class CsvMappingBuilder2 extends AbstractCsvMappingBuilder> {

	private Class intermediate;
	
	public CsvMappingBuilder2(Class cls, Class intermediate) {
		super(cls);
		
		this.intermediate = intermediate;
	}

	public CsvMapper2 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 CsvMapper2(target, intermediate, divider, quoteCharacter, escapeCharacter, columns, skipEmptyLines, skipComments, skippableFieldsWithoutLinebreaks, classLoader, bufferLength);
	}

	public StringCsvFieldMapperTriBuilder> stringField(String name) {
		return new StringCsvFieldMapperTriBuilder>(this, name, intermediate);
	}
	
	public Class getIntermediate() {
		return intermediate;
	}

	public CsvFieldMapperTriBuilder> field(String name) {
		return new CsvFieldMapperTriBuilder>(this, name, intermediate);
	}

	public DoubleCsvFieldMapperTriBuilder> doubleField(String name) {
		return new DoubleCsvFieldMapperTriBuilder>(this, name, intermediate);
	}
	
	public LongCsvFieldMapperTriBuilder> longField(String name) {
		return new LongCsvFieldMapperTriBuilder>(this, name, intermediate);
	}
	
	public IntCsvFieldMapperTriBuilder> integerField(String name) {
		return new IntCsvFieldMapperTriBuilder>(this, name, intermediate);
	}

	public BooleanCsvFieldMapperTriBuilder> booleanField(String name) {
		return new BooleanCsvFieldMapperTriBuilder>(this, name, intermediate);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy