Interface ColumnMapper

  • All Superinterfaces:
    java.lang.Cloneable
    All Known Implementing Classes:
    ColumnMapping

    public interface ColumnMapper
    extends java.lang.Cloneable
    A utility that allows users to manually define mappings from attributes/methods of a given class to columns to be parsed or written. This removes the requirement of having classes annotated with Parsed or Nested. Mappings defined manually take precedence over annotations.
    See Also:
    ColumnMapping
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void attributesToColumnNames​(java.util.Map<java.lang.String,​java.lang.String> mappings)
      Maps multiple attributes to multiple column names.
      void attributesToColumns​(java.util.Map<java.lang.String,​java.lang.Enum<?>> mappings)
      Maps multiple attributes to multiple columns.
      void attributesToIndexes​(java.util.Map<java.lang.String,​java.lang.Integer> mappings)
      Maps multiple attributes to multiple column positions.
      void attributeToColumn​(java.lang.String attributeName, java.lang.Enum<?> column)
      Maps an attribute to a column.
      void attributeToColumnName​(java.lang.String attributeName, java.lang.String columnName)
      Maps an attribute to a column name.
      void attributeToIndex​(java.lang.String attributeName, int columnIndex)
      Maps an attribute to a column position.
      ColumnMapper clone()
      Creates a deep copy of this object with all its mappings.
      void methodsToColumnNames​(java.util.Map<java.lang.String,​java.lang.String> mappings)
      Maps multiple methods to multiple column names.
      void methodsToColumns​(java.util.Map<java.lang.String,​java.lang.Enum<?>> mappings)
      Maps multiple methods to multiple columns.
      void methodsToIndexes​(java.util.Map<java.lang.String,​java.lang.Integer> mappings)
      Maps multiple methods to multiple column positions.
      void methodToColumn​(java.lang.String setterName, java.lang.Class<?> parameterType, java.lang.Enum<?> column)
      Maps a setter method to a column.
      void methodToColumn​(java.lang.String methodName, java.lang.Enum<?> column)
      Maps a method to a column.
      void methodToColumnName​(java.lang.String setterName, java.lang.Class<?> parameterType, java.lang.String columnName)
      Maps a setter method to a column name.
      void methodToColumnName​(java.lang.String methodName, java.lang.String columnName)
      Maps a method to a column name.
      void methodToIndex​(java.lang.String methodName, int columnIndex)
      Maps a method to a column position.
      void methodToIndex​(java.lang.String setterName, java.lang.Class<?> parameterType, int columnIndex)
      Maps a setter method to a column position.
      void remove​(java.lang.String methodOrAttributeName)
      Removes any mappings that target a given method or attribute name.
    • Method Detail

      • attributeToColumnName

        void attributeToColumnName​(java.lang.String attributeName,
                                   java.lang.String columnName)
        Maps an attribute to a column name.
        Parameters:
        attributeName - the name of the attribute. Use the dot character to access attributes of nested objects, e.g. contact.mobile will target the attribute "mobile" from a Contact attribute inside a Customer class.
        columnName - the name of the column that: (a) when parsing, will be read from to populate the given attribute of an object; (b) when writing, will receive the value of the given attribute of an object;
      • attributeToColumn

        void attributeToColumn​(java.lang.String attributeName,
                               java.lang.Enum<?> column)
        Maps an attribute to a column.
        Parameters:
        attributeName - the name of the attribute. Use the dot character to access attributes of nested objects, e.g. contact.mobile will target the attribute "mobile" from a Contact attribute inside a Customer class.
        column - an enumeration representing the column that: (a) when parsing, will be read from to populate the given attribute of an object; (b) when writing, will receive the value of the given attribute of an object;
      • attributeToIndex

        void attributeToIndex​(java.lang.String attributeName,
                              int columnIndex)
        Maps an attribute to a column position.
        Parameters:
        attributeName - the name of the attribute. Use the dot character to access attributes of nested objects, e.g. contact.mobile will target the attribute "mobile" from a Contact attribute inside a Customer class.
        columnIndex - the position of the column that: (a) when parsing, will be read from to populate the given attribute of an object; (b) when writing, will receive the value of the given attribute of an object;
      • attributesToColumnNames

        void attributesToColumnNames​(java.util.Map<java.lang.String,​java.lang.String> mappings)
        Maps multiple attributes to multiple column names.
        Parameters:
        mappings - a map of attribute names associated with a corresponding column name, where:
        • Each key is the name of the attribute. Use the dot character to access attributes of nested objects, e.g. contact.mobile will target the attribute "mobile" from a Contact attribute inside a Customer class.
        • Each value is the name of the column that: (a) when parsing, will be read from to populate the given attribute of an object; (b) when writing, will receive the value of the given attribute of an object;
      • attributesToColumns

        void attributesToColumns​(java.util.Map<java.lang.String,​java.lang.Enum<?>> mappings)
        Maps multiple attributes to multiple columns.
        Parameters:
        mappings - a map of attribute names associated with a corresponding column, where:
        • Each key is the name of the attribute. Use the dot character to access attributes of nested objects, e.g. contact.mobile will target the attribute "mobile" from a Contact attribute inside a Customer class.
        • Each value is an enumeration representing the column that: (a) when parsing, will be read from to populate the given attribute of an object; (b) when writing, will receive the value of the given attribute of an object;
      • attributesToIndexes

        void attributesToIndexes​(java.util.Map<java.lang.String,​java.lang.Integer> mappings)
        Maps multiple attributes to multiple column positions.
        Parameters:
        mappings - a map of attribute names associated with a corresponding column, where:
        • Each key is the name of the attribute. Use the dot character to access attributes of nested objects, e.g. contact.mobile will target the attribute "mobile" from a Contact attribute inside a Customer class.
        • Each value is an integer representing the position of the column that: (a) when parsing, will be read from to populate the given attribute of an object; (b) when writing, will receive the value of the given attribute of an object;
      • methodToColumnName

        void methodToColumnName​(java.lang.String setterName,
                                java.lang.Class<?> parameterType,
                                java.lang.String columnName)
        Maps a setter method to a column name. Use when methodToColumnName(String, String) is not enough to uniquely identify the method you need (e.g. when there are overloaded methods with different parameter types) Used only for parsing. Will be ignored when writing.
        Parameters:
        setterName - the name of the setter method. Use the dot character to access methods of nested objects, e.g. contact.mobile will target the setter method "mobile(String)" from a Contact attribute inside a Customer class.
        parameterType - the type of the parameter used in the given setter name.
        columnName - the name of the column that when parsing, will be read from to invoke given setter method of an object
      • methodToColumn

        void methodToColumn​(java.lang.String setterName,
                            java.lang.Class<?> parameterType,
                            java.lang.Enum<?> column)
        Maps a setter method to a column. Use when methodToColumnName(String, String) is not enough to uniquely identify the method you need (e.g. when there are overloaded methods with different parameter types) Used only for parsing. Will be ignored when writing.
        Parameters:
        setterName - the name of the setter method. Use the dot character to access methods of nested objects, e.g. contact.mobile will target the setter method "mobile(String)" from a Contact attribute inside a Customer class.
        parameterType - the type of the parameter used in the given setter name.
        column - an enumeration representing the column that when parsing, will be read from to invoke given setter method of an object
      • methodToIndex

        void methodToIndex​(java.lang.String setterName,
                           java.lang.Class<?> parameterType,
                           int columnIndex)
        Maps a setter method to a column position. Use when methodToColumnName(String, String) is not enough to uniquely identify the method you need (e.g. when there are overloaded methods with different parameter types) Used only for parsing. Will be ignored when writing.
        Parameters:
        setterName - the name of the setter method. Use the dot character to access methods of nested objects, e.g. contact.mobile will target the setter method "mobile(String)" from a Contact attribute inside a Customer class.
        parameterType - the type of the parameter used in the given setter name.
        columnIndex - the position of the column that when parsing, will be read from to invoke given setter method of an object
      • methodToColumnName

        void methodToColumnName​(java.lang.String methodName,
                                java.lang.String columnName)
        Maps a method to a column name. When parsing, only "setter" methods will be used i.e. the given method accepts one parameter. If the method is overridden, use methodToColumnName(String, Class, String) to specify the exact parameter type to match the appropriate setter method. When writing, only "getter" methods will be used i.e. the given method doesn't accept any parameters and returns a value.
        Parameters:
        methodName - the name of the method. Use the dot character to access methods of nested objects, e.g. contact.mobile will target the method "mobile(String)" when parsing, or "String mobile()" when writing, from a Contact attribute inside a Customer class.
        columnName - the name of the column that: (a) when parsing, will be read from to invoke given setter method of an object; (b) when writing, will receive the value returned by the given getter method of an object;
      • methodToColumn

        void methodToColumn​(java.lang.String methodName,
                            java.lang.Enum<?> column)
        Maps a method to a column. When parsing, only "setter" methods will be used i.e. the given method accepts one parameter. If the method is overridden, use methodToColumnName(String, Class, String) to specify the exact parameter type to match the appropriate setter method. When writing, only "getter" methods will be used i.e. the given method doesn't accept any parameters and returns a value.
        Parameters:
        methodName - the name of the method. Use the dot character to access methods of nested objects, * e.g. contact.mobile will target the method "mobile(String)" when parsing, or "String mobile()" when writing, * from a Contact attribute inside a Customer class.
        column - an enumeration representing the column that: (a) when parsing, will be read from to invoke given setter method of an object; (b) when writing, will receive the value returned by the given getter method of an object;
      • methodToIndex

        void methodToIndex​(java.lang.String methodName,
                           int columnIndex)
        Maps a method to a column position. When parsing, only "setter" methods will be used i.e. the given method accepts one parameter. If the method is overridden, use methodToColumnName(String, Class, String) to specify the exact parameter type to match the appropriate setter method. When writing, only "getter" methods will be used i.e. the given method doesn't accept any parameters and returns a value.
        Parameters:
        methodName - the name of the method. Use the dot character to access methods of nested objects, * e.g. contact.mobile will target the method "mobile(String)" when parsing, or "String mobile()" when writing, * from a Contact attribute inside a Customer class.
        columnIndex - the position of the column that: (a) when parsing, will be read from to invoke given setter method of an object; (b) when writing, will receive the value returned by the given getter method of an object;
      • methodsToColumnNames

        void methodsToColumnNames​(java.util.Map<java.lang.String,​java.lang.String> mappings)
        Maps multiple methods to multiple column names.
        Parameters:
        mappings - a map of methods names associated with a corresponding column name, where:
        • Each key is the name of a method. Use the dot character to access attributes of nested objects, e.g. contact.mobile will target the method "mobile(String)" when parsing, or "String mobile()" when writing, from a Contact attribute inside a Customer class.
        • Each value is the name of the column that: (a) when parsing, will be read from to invoke given setter method of an object; (b) when writing, will receive the value returned by the given getter method of an object;
      • methodsToColumns

        void methodsToColumns​(java.util.Map<java.lang.String,​java.lang.Enum<?>> mappings)
        Maps multiple methods to multiple columns.
        Parameters:
        mappings - a map of methods names associated with a corresponding column, where:
        • Each key is the name of a method. Use the dot character to access attributes of nested objects, e.g. contact.mobile will target the method "mobile(String)" when parsing, or "String mobile()" when writing, from a Contact attribute inside a Customer class.
        • Each value is an enumeration representing the column that: (a) when parsing, will be read from to invoke given setter method of an object; (b) when writing, will receive the value returned by the given getter method of an object;
      • methodsToIndexes

        void methodsToIndexes​(java.util.Map<java.lang.String,​java.lang.Integer> mappings)
        Maps multiple methods to multiple column positions.
        Parameters:
        mappings - a map of methods names associated with a corresponding column position, where:
        • Each key is the name of a method. Use the dot character to access attributes of nested objects, e.g. contact.mobile will target the method "mobile(String)" when parsing, or "String mobile()" when writing, from a Contact attribute inside a Customer class.
        • Each value is an integer representing the position of the column that: (a) when parsing, will be read from to invoke given setter method of an object; (b) when writing, will receive the value returned by the given getter method of an object;
      • clone

        ColumnMapper clone()
        Creates a deep copy of this object with all its mappings. Changes to the clone won't affect the original instance.
        Returns:
        a clone of the current mappings.
      • remove

        void remove​(java.lang.String methodOrAttributeName)
        Removes any mappings that target a given method or attribute name.
        Parameters:
        methodOrAttributeName - the name of the method or attribute to be removed.