
@Target(value=METHOD) @Retention(value=CLASS) public @interface MapMapping
Example:
 @Mapper
 public interface SimpleMapper {
       @MapMapping(valueDateFormat = "dd.MM.yyyy")
       Map<String, String> longDateMapToStringStringMap(Map<Long, Date> source);
 }
 
 // generates
 public class SimpleMapperImpl implements SimpleMapper {
      @Override
      public Map<String, String> longDateMapToStringStringMap(Map<Long, Date> source) } {
          Map<String, String> map = new HashMap<String, String>(); }
          for ( java.util.Map.Entry<Long, Date> entry : source.entrySet() ) } {
              String key = new DecimalFormat( "" ).format( entry.getKey() );
              String value = new SimpleDateFormat( "dd.MM.yyyy" ).format( entry.getValue() );
              map.put( key, value );
          }
          // ...
      }
 }
 NOTE: at least one element needs to be specified
| Modifier and Type | Optional Element and Description | 
|---|---|
| String | keyDateFormatA format string as processable by  SimpleDateFormatif the annotated method maps from a map with key typeStringto an map with key typeDateor vice-versa. | 
| Class<? extends Annotation> | keyMappingControlAllows detailed control over the key mapping process. | 
| String | keyNumberFormatA format string as processable by  DecimalFormatif the annotated method maps from aNumberto aStringor vice-versa. | 
| Class<? extends Annotation>[] | keyQualifiedByA key value qualifier can be specified to aid the selection process of a suitable mapper. | 
| String[] | keyQualifiedByNameString-based form of qualifiers; When looking for a suitable mapping method to map this map mapping method's key
 type, MapStruct will only consider those methods carrying directly or indirectly (i.e. on the class-level) a
  Namedannotation for each of the specified qualifier names. | 
| Class<?> | keyTargetTypeSpecifies the type of the key to be used in the result of the mapping method in case multiple mapping
 methods qualify. | 
| NullValueMappingStrategy | nullValueMappingStrategyThe strategy to be applied when  nullis passed as source value to this map mapping. | 
| String | valueDateFormatA format string as processable by  SimpleDateFormatif the annotated method maps from a map with value
 typeStringto an map with value typeDateor vice-versa. | 
| Class<? extends Annotation> | valueMappingControlAllows detailed control over the value mapping process. | 
| String | valueNumberFormatA format string as processable by  DecimalFormatif the annotated method maps from aNumberto aStringor vice-versa. | 
| Class<? extends Annotation>[] | valueQualifiedByA value qualifier can be specified to aid the selection process of a suitable mapper for the values in the map. | 
| String[] | valueQualifiedByNameString-based form of qualifiers; When looking for a suitable mapping method to map this map mapping method's
 value type, MapStruct will only consider those methods carrying directly or indirectly (i.e. on the class-level)
 a  Namedannotation for each of the specified qualifier names. | 
| Class<?> | valueTargetTypeSpecifies the type of the value to be used in the result of the mapping method in case multiple mapping
 methods qualify. | 
public abstract String keyDateFormat
SimpleDateFormat if the annotated method maps from a map with key type
 String to an map with key type Date or vice-versa. Will be ignored for all other key types.SimpleDateFormat.public abstract String valueDateFormat
SimpleDateFormat if the annotated method maps from a map with value
 type String to an map with value type Date or vice-versa. Will be ignored for all other value
 types.SimpleDateFormat.public abstract String keyNumberFormat
DecimalFormat if the annotated method maps from a
  Number to a String or vice-versa. Will be ignored for all other key types.DecimalFormat.public abstract String valueNumberFormat
DecimalFormat if the annotated method maps from a
  Number to a String or vice-versa. Will be ignored for all other value types.DecimalFormat.public abstract Class<? extends Annotation>[] keyQualifiedBy
Qualifierpublic abstract String[] keyQualifiedByName
Named annotation for each of the specified qualifier names.
 Note that annotation-based qualifiers are generally preferable as they allow more easily to find references and are safe for refactorings, but name-based qualifiers can be a less verbose alternative when requiring a large number of qualifiers as no custom annotation types are needed.
keyQualifiedBy(), 
Namedpublic abstract Class<? extends Annotation>[] valueQualifiedBy
A qualifier is a custom annotation and can be placed on either a hand written mapper class or a method.
Qualifierpublic abstract String[] valueQualifiedByName
Named annotation for each of the specified qualifier names.
 Note that annotation-based qualifiers are generally preferable as they allow more easily to find references and are safe for refactorings, but name-based qualifiers can be a less verbose alternative when requiring a large number of qualifiers as no custom annotation types are needed.
valueQualifiedBy(), 
Namedpublic abstract Class<?> keyTargetType
public abstract Class<?> valueTargetType
public abstract NullValueMappingStrategy nullValueMappingStrategy
null is passed as source value to this map mapping. If no
 strategy is configured, the strategy given via MapperConfig.nullValueMappingStrategy() or
 Mapper.nullValueMappingStrategy() will be applied, using NullValueMappingStrategy.RETURN_NULL
 by default.null is passed as source value to the methods of this mapping.public abstract Class<? extends Annotation> keyMappingControl
DeepClone, 
NoComplexMapping, 
MappingControlpublic abstract Class<? extends Annotation> valueMappingControl
DeepClone, 
NoComplexMapping, 
MappingControlCopyright © 2012-2021 MapStruct Authors; All rights reserved. Released under the Apache Software License 2.0.