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

com.github.skjolber.stcsv.databinder.column.bi.CsvFieldMapperBuilder Maven / Gradle / Ivy

There is a newer version: 1.0.25
Show newest version
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 + "'");
	}

}






© 2015 - 2024 Weber Informatics LLC | Privacy Policy