com.opencsv.bean.HeaderColumnNameTranslateMappingStrategyBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opencsv Show documentation
Show all versions of opencsv Show documentation
A simple library for reading and writing CSV in Java
package com.opencsv.bean;
/**
* Builder for a {@link HeaderColumnNameMappingStrategy}.
* This allows opencsv to introduce new options for mapping strategies
* while maintaining backward compatibility and without creating
* reams of constructors for the mapping strategy.
*
* @param The type of the bean being processed
* @since 5.5
* @author Andrew Rucker Jones
*/
public class HeaderColumnNameTranslateMappingStrategyBuilder {
private boolean forceCorrectRecordLength = false;
/** Default constructor. */
public HeaderColumnNameTranslateMappingStrategyBuilder() {}
/**
* Builds a new mapping strategy for parsing/writing.
* @return A new mapping strategy using the options selected
*/
public HeaderColumnNameTranslateMappingStrategy build() {
return new HeaderColumnNameTranslateMappingStrategy<>(forceCorrectRecordLength);
}
/**
* Insists that every record will be considered to be of the correct
* length (that is, the same number of columns as the header).
* Excess fields at the end of a record will be ignored. Missing
* fields at the end of a record will be interpreted as {@code null}.
* This is only relevant on reading.
* If not set, incorrect record length will throw an exception. That
* is, the default value is {@code false}.
*
* @param forceCorrectRecordLength Whether records should be forced to
* the correct length
* @return {@code this}
*/
public HeaderColumnNameTranslateMappingStrategyBuilder withForceCorrectRecordLength(boolean forceCorrectRecordLength) {
this.forceCorrectRecordLength = forceCorrectRecordLength;
return this;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy