Package org.mapstruct

Annotation Type Mappings


@Retention(CLASS) @Target({METHOD,ANNOTATION_TYPE}) public @interface Mappings
Configures the mappings of several bean attributes.

TIP: When using Java 8 or later, you can omit the @Mappings wrapper annotation and directly specify several @Mapping annotations on one method.

These two examples are equal.


 // before Java 8
 @Mapper
 public interface MyMapper {
     @Mappings({
         @Mapping(target = "firstProperty", source = "first"),
         @Mapping(target = "secondProperty", source = "second")
     })
     HumanDto toHumanDto(Human human);
 }
 

 // Java 8 and later
 @Mapper
 public interface MyMapper {
     @Mapping(target = "firstProperty", source = "first"),
     @Mapping(target = "secondProperty", source = "second")
     HumanDto toHumanDto(Human human);
 }
 
Author:
Gunnar Morling
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The configuration of the bean attributes.
  • Element Details

    • value

      Mapping[] value
      The configuration of the bean attributes.
      Returns:
      The configuration of the bean attributes.