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

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

The newest version!
package com.opencsv.bean;

/**
 * Builder for a {@link FuzzyMappingStrategy}.
 * 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 FuzzyMappingStrategyBuilder {

    private boolean forceCorrectRecordLength = false;

    /** Default constructor. */
    public FuzzyMappingStrategyBuilder() {}

    /**
     * Builds a new mapping strategy for parsing/writing.
     * @return A new mapping strategy using the options selected
     */
    public FuzzyMappingStrategy build() {
        return new FuzzyMappingStrategy<>(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 FuzzyMappingStrategyBuilder withForceCorrectRecordLength(boolean forceCorrectRecordLength) { this.forceCorrectRecordLength = forceCorrectRecordLength; return this; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy