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

com.opencsv.bean.HeaderColumnNameTranslateMappingStrategyBuilder Maven / Gradle / Ivy

There is a newer version: 5.9
Show newest version
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