K
- the type of key (attribute/method names or specific method definition with parameter and return types)abstract class AbstractColumnMapping<K>
extends java.lang.Object
implements java.lang.Cloneable
ColumnMapper
Modifier and Type | Field and Description |
---|---|
(package private) java.util.Map<K,java.lang.Object> |
mapping |
(package private) java.lang.String |
prefix |
Constructor and Description |
---|
AbstractColumnMapping(java.lang.String prefix,
AbstractColumnMapping parent)
Creates a mapping with a prefix.
|
Modifier and Type | Method and Description |
---|---|
AbstractColumnMapping<K> |
clone()
Creates a deep copy of this mapping that is independent from the original.
|
(package private) void |
extractPrefixes(java.util.Set<java.lang.String> out)
Returns all prefixes used by the keys in this mapping.
|
(package private) abstract K |
findKey(java.lang.String nameWithPrefix)
Locates a given key based on an attribute or method name.
|
(package private) abstract java.lang.String |
getKeyPrefix(java.lang.String prefix,
K key)
Returns the prefix of a given key, i.e.
|
private java.lang.Object |
getMappedColumn(K key) |
(package private) boolean |
isMapped(K key)
Tests whether a given attribute or method is mapped to a column
|
(package private) void |
mapToColumn(K key,
java.lang.Enum<?> column)
Maps a attribute or method to a column name
|
(package private) void |
mapToColumnIndex(K key,
int columnIndex)
Maps a attribute or method to a column name
|
(package private) void |
mapToColumnIndexes(java.util.Map<K,java.lang.Integer> mappings)
Maps multiple attributes or methods to multiple column names
|
(package private) void |
mapToColumnName(K key,
java.lang.String columnName)
Maps a attribute or method to a column name
|
(package private) void |
mapToColumnNames(java.util.Map<K,java.lang.String> mappings)
Maps multiple attributes or methods to multiple column names
|
(package private) void |
mapToColumns(java.util.Map<K,java.lang.Enum<?>> mappings)
Maps multiple attributes or methods to multiple column names
|
(package private) abstract K |
prefixKey(java.lang.String prefix,
K key)
Transforms the key so it can work with the given prefix.
|
(package private) void |
remove(java.lang.String nameWithPrefix)
Removes any mappings containing keys that have a given attribute or method name.
|
(package private) boolean |
updateFieldMapping(FieldMapping fieldMapping,
K key)
Updates the mapping of a attribute/method so a mapped class member can target
a user provided column.
|
final java.lang.String prefix
java.util.Map<K,java.lang.Object> mapping
AbstractColumnMapping(java.lang.String prefix, AbstractColumnMapping parent)
prefix
- a dot separated sequence of names that represents the nesting of complex attributes inside a class (e.g customer.contact.phone).parent
- the parent mapping of columns, relevant only when nested objects' attributes or methods are being mapped.void mapToColumnName(K key, java.lang.String columnName)
key
- attribute/method name or specific method definition with parameter and return typecolumnName
- name of column associated with the given keyvoid mapToColumn(K key, java.lang.Enum<?> column)
key
- attribute/method name or specific method definition with parameter and return typecolumn
- enumeration representing the column associated with the given keyvoid mapToColumnIndex(K key, int columnIndex)
key
- attribute/method name or specific method definition with parameter and return typecolumnIndex
- number representing the position of the column associated with the given keyvoid mapToColumnNames(java.util.Map<K,java.lang.String> mappings)
mappings
- the mappings to be addedvoid mapToColumns(java.util.Map<K,java.lang.Enum<?>> mappings)
mappings
- the mappings to be addedvoid mapToColumnIndexes(java.util.Map<K,java.lang.Integer> mappings)
mappings
- the mappings to be addedboolean isMapped(K key)
key
- the attribute or method name/descriptortrue
if the key is mapped.abstract K prefixKey(java.lang.String prefix, K key)
prefix
- the current object nesting level, denoted by a dot-separated string of nested attribute names.key
- the key to transform.null
if the key can't be used with the given prefixprivate java.lang.Object getMappedColumn(K key)
boolean updateFieldMapping(FieldMapping fieldMapping, K key)
fieldMapping
- a class member that has should be mapped to a columnkey
- the attribute name or method specification that matches with the given field.true
if the mapping has been successfully updated.void extractPrefixes(java.util.Set<java.lang.String> out)
out
- the set of prefixes to populate.abstract java.lang.String getKeyPrefix(java.lang.String prefix, K key)
prefix
- the current prefix - a dot separated string with nested attribute nameskey
- the attribute name or method definition. If its own prefix starts with the given prefix, the next element after the dot will be returned (if any)public AbstractColumnMapping<K> clone()
clone
in class java.lang.Object
abstract K findKey(java.lang.String nameWithPrefix)
nameWithPrefix
- name of the attribute or method, prefixed with nested object names that identify the path to the target class member.void remove(java.lang.String nameWithPrefix)
nameWithPrefix
- name of the attribute or method, prefixed with nested object names that identify the path to the target class member.