Package com.expediagroup.map.transformer
Class MapTransformerImpl
java.lang.Object
com.expediagroup.transformer.AbstractTransformer<MapTransformer,java.lang.Object,MapTransformerSettings>
com.expediagroup.map.transformer.MapTransformerImpl
- All Implemented Interfaces:
MapTransformer
,Transformer<MapTransformer>
public class MapTransformerImpl extends AbstractTransformer<MapTransformer,java.lang.Object,MapTransformerSettings>
Utility methods for populating
Map
elements via reflection.-
Field Summary
Fields inherited from class com.expediagroup.transformer.AbstractTransformer
cacheManager, classUtils, reflectionUtils, settings, transformerFunctionRegex
-
Constructor Summary
Constructors Constructor Description MapTransformerImpl()
-
Method Summary
Modifier and Type Method Description void
resetKeyTransformer()
Removes all the configured key transformer.<T, K> java.util.Map<T,K>
transform(java.util.Map<T,K> sourceMap)
Copies all properties from a map to a new one applying the transformation function and mappings defined.<T, K> java.util.Map<T,K>
transform(java.util.Map<T,K> sourceMap, BeanTransformer beanTransformer)
Copies all properties from a map to a new one applying the transformation function and mappings defined.<T, K, R, V> java.util.Map<R,V>
transform(java.util.Map<T,K> sourceMap, BeanTransformer beanTransformer, java.lang.Class<R> targetKeyType, java.lang.Class<V> targetElemType)
Copies all properties from a map to a new one applying the transformation function and mappings defined.<T, K, R, V> java.util.Map<R,V>
transform(java.util.Map<T,K> sourceMap, java.lang.Class<R> targetKeyType, java.lang.Class<V> targetElemType)
Copies all properties from a map to a new one applying the transformation function and mappings defined.MapTransformer
withKeyTransformer(FieldTransformer... keyFieldTransformer)
Initializes the transformer functions to apply on a Map key.Methods inherited from class com.expediagroup.transformer.AbstractTransformer
removeFieldMapping, removeFieldTransformer, reset, resetFieldsMapping, resetFieldsTransformer, withFieldMapping, withFieldTransformer
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.expediagroup.transformer.Transformer
removeFieldMapping, removeFieldTransformer, reset, resetFieldsMapping, resetFieldsTransformer, withFieldMapping, withFieldTransformer
-
Constructor Details
-
MapTransformerImpl
public MapTransformerImpl()
-
-
Method Details
-
transform
public <T, K> java.util.Map<T,K> transform(java.util.Map<T,K> sourceMap, BeanTransformer beanTransformer)Copies all properties from a map to a new one applying the transformation function and mappings defined.- Type Parameters:
T
- the key object type in the source mapK
- the elem object type in the source map- Parameters:
sourceMap
- the source mapbeanTransformer
- the bean transformer to use for the map elements transformation- Returns:
- a copy of the source object into the destination object
-
transform
public <T, K, R, V> java.util.Map<R,V> transform(java.util.Map<T,K> sourceMap, BeanTransformer beanTransformer, java.lang.Class<R> targetKeyType, java.lang.Class<V> targetElemType)Copies all properties from a map to a new one applying the transformation function and mappings defined.- Type Parameters:
T
- the key object type in the source mapK
- the elem object type in the source mapR
- the key object type in the target mapV
- the elem object type in the target map- Parameters:
sourceMap
- the source mapbeanTransformer
- the bean transformer to use for the map elements transformationtargetKeyType
- the key type in the target maptargetElemType
- the elem type in the target map- Returns:
- a copy of the source object into the destination object
-
transform
public <T, K> java.util.Map<T,K> transform(java.util.Map<T,K> sourceMap)Copies all properties from a map to a new one applying the transformation function and mappings defined.- Specified by:
transform
in interfaceMapTransformer
- Type Parameters:
T
- the key object type in the source mapK
- the elem object type in the source map- Parameters:
sourceMap
- the source map- Returns:
- a copy of the source object into the destination object
-
transform
public <T, K, R, V> java.util.Map<R,V> transform(java.util.Map<T,K> sourceMap, java.lang.Class<R> targetKeyType, java.lang.Class<V> targetElemType)Copies all properties from a map to a new one applying the transformation function and mappings defined.- Specified by:
transform
in interfaceMapTransformer
- Type Parameters:
T
- the key object type in the source mapK
- the elem object type in the source mapR
- the key object type in the target mapV
- the elem object type in the target map- Parameters:
sourceMap
- the source maptargetKeyType
- the key type in the target maptargetElemType
- the elem type in the target map- Returns:
- a copy of the source object into the destination object
-
withKeyTransformer
Initializes the transformer functions to apply on a Map key. The transformer function returns directly the field value.- Specified by:
withKeyTransformer
in interfaceMapTransformer
- Parameters:
keyFieldTransformer
- the fields transformer function- Returns:
- the
Transformer
instance
-
resetKeyTransformer
public final void resetKeyTransformer()Removes all the configured key transformer.- Specified by:
resetKeyTransformer
in interfaceMapTransformer
-