Interface MapTransformer

All Superinterfaces:
Transformer<MapTransformer>
All Known Implementing Classes:
MapTransformerImpl

public interface MapTransformer
extends Transformer<MapTransformer>
Utility methods for populating Map elements via reflection. The implementations are provided by 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.
  • Method Details

    • transform

      <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.
      Type Parameters:
      T - the key object type in the source map
      K - the elem object type in the source map
      Parameters:
      sourceMap - the source map
      Returns:
      a copy of the source object into the destination object
      Throws:
      java.lang.IllegalArgumentException - if any parameter is invalid
    • transform

      <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 map
      K - the elem object type in the source map
      Parameters:
      sourceMap - the source map
      beanTransformer - the bean transformer to use for the map elements transformation
      Returns:
      a copy of the source object into the destination object
      Throws:
      java.lang.IllegalArgumentException - if any parameter is invalid
    • transform

      <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.
      Type Parameters:
      T - the key object type in the source map
      K - the elem object type in the source map
      R - the key object type in the target map
      V - the elem object type in the target map
      Parameters:
      sourceMap - the source map
      targetKeyType - the key type in the target map
      targetElemType - the elem type in the target map
      Returns:
      a copy of the source object into the destination object
      Throws:
      java.lang.IllegalArgumentException - if any parameter is invalid
    • transform

      <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 map
      K - the elem object type in the source map
      R - the key object type in the target map
      V - the elem object type in the target map
      Parameters:
      sourceMap - the source map
      beanTransformer - the bean transformer to use for the map elements transformation
      targetKeyType - the key type in the target map
      targetElemType - the elem type in the target map
      Returns:
      a copy of the source object into the destination object
      Throws:
      java.lang.IllegalArgumentException - if any parameter is invalid
    • withKeyTransformer

      MapTransformer withKeyTransformer​(FieldTransformer... keyFieldTransformer)
      Initializes the transformer functions to apply on a Map key. The transformer function returns directly the field value.
      Parameters:
      keyFieldTransformer - the fields transformer function
      Returns:
      the Transformer instance
    • resetKeyTransformer

      void resetKeyTransformer()
      Removes all the configured key transformer.