Class HeaderColumnNameTranslateMappingStrategy<T>

  • Type Parameters:
    T - Class to be mapped.
    All Implemented Interfaces:
    MappingStrategy<T>

    public class HeaderColumnNameTranslateMappingStrategy<T>
    extends HeaderNameBaseMappingStrategy<T>
    Expands on HeaderColumnNameMappingStrategy by allowing the user to pass in a map of column names to bean names. This way the fields in the bean do not have to match the fields in the CSV file. This is only for when the user passes in the header names programmatically, and not for annotated beans.
    • Field Detail

      • columnMapping

        private final java.util.Map<java.lang.String,​java.lang.String> columnMapping
    • Constructor Detail

      • HeaderColumnNameTranslateMappingStrategy

        public HeaderColumnNameTranslateMappingStrategy​(boolean forceCorrectRecordLength)
        Constructor to allow setting options for header name mapping. Not considered stable. As new options are introduced for the mapping strategy, they will be introduced here. You are encouraged to use HeaderColumnNameTranslateMappingStrategyBuilder.
        Parameters:
        forceCorrectRecordLength - If set, every record will be shortened or lengthened to match the number of headers
        See Also:
        HeaderColumnNameTranslateMappingStrategyBuilder
    • Method Detail

      • getColumnName

        public java.lang.String getColumnName​(int col)
        Description copied from class: AbstractMappingStrategy
        Get the column name for a given column position.
        Overrides:
        getColumnName in class AbstractMappingStrategy<java.lang.String,​java.lang.String,​ComplexFieldMapEntry<java.lang.String,​java.lang.String,​T>,​T>
        Parameters:
        col - Column position.
        Returns:
        The column name or null if the position is larger than the header array or there are no headers defined.
      • getColumnMapping

        public java.util.Map<java.lang.String,​java.lang.String> getColumnMapping()
        Retrieves the column mappings of the strategy.
        Returns:
        The column mappings of the strategy.
      • setColumnMapping

        public void setColumnMapping​(java.util.Map<java.lang.String,​java.lang.String> columnMapping)
        Sets the column mapping to those passed in.
        Parameters:
        columnMapping - Source column mapping.