Class HeaderColumnNameMappingStrategy<T>

  • Type Parameters:
    T - Type of the bean to be returned
    All Implemented Interfaces:
    MappingStrategy<T>
    Direct Known Subclasses:
    FuzzyMappingStrategy

    public class HeaderColumnNameMappingStrategy<T>
    extends HeaderNameBaseMappingStrategy<T>
    Maps data to objects using the column names in the first row of the CSV file as reference. This way the column order does not matter.
    • Constructor Detail

      • HeaderColumnNameMappingStrategy

        public HeaderColumnNameMappingStrategy​(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 HeaderColumnNameMappingStrategyBuilder.
        Parameters:
        forceCorrectRecordLength - If set, every record will be shortened or lengthened to match the number of headers
        See Also:
        HeaderColumnNameMappingStrategyBuilder
    • Method Detail

      • registerCustomBinding

        private void registerCustomBinding​(CsvCustomBindByName annotation,
                                           java.lang.Class<?> localType,
                                           java.lang.reflect.Field localField)
        Register a binding between a bean field and a custom converter.
        Parameters:
        annotation - The annotation attached to the bean field
        localType - The class/type in which the field resides
        localField - The bean field
      • registerSplitBinding

        private void registerSplitBinding​(CsvBindAndSplitByName annotation,
                                          java.lang.Class<?> localType,
                                          java.lang.reflect.Field localField)
        Register a binding between a bean field and a collection converter that splits input into multiple values.
        Parameters:
        annotation - The annotation attached to the bean field
        localType - The class/type in which the field resides
        localField - The bean field
      • registerJoinBinding

        private void registerJoinBinding​(CsvBindAndJoinByName annotation,
                                         java.lang.Class<?> localType,
                                         java.lang.reflect.Field localField)
        Register a binding between a bean field and a multi-valued converter that joins values from multiple columns.
        Parameters:
        annotation - The annotation attached to the bean field
        localType - The class/type in which the field resides
        localField - The bean field
      • registerBinding

        private void registerBinding​(CsvBindByName annotation,
                                     java.lang.Class<?> localType,
                                     java.lang.reflect.Field localField)
        Register a binding between a bean field and a simple converter.
        Parameters:
        annotation - The annotation attached to the bean field
        localType - The class/type in which the field resides
        localField - The bean field
      • loadAnnotatedFieldMap

        protected void loadAnnotatedFieldMap​(org.apache.commons.collections4.ListValuedMap<java.lang.Class<?>,​java.lang.reflect.Field> fields)
        Creates a map of annotated fields in the bean to be processed.

        This method is called by AbstractMappingStrategy.loadFieldMap() when at least one relevant annotation is found on a member variable.

        Overrides:
        loadAnnotatedFieldMap in class AbstractMappingStrategy<java.lang.String,​java.lang.String,​ComplexFieldMapEntry<java.lang.String,​java.lang.String,​T>,​T>
        Parameters:
        fields - A list of fields annotated with a binding annotation in the bean to be processed