Package org.mapstruct

Annotation Type SubclassMappings


  • @Target({METHOD,ANNOTATION_TYPE})
    @Retention(CLASS)
    @Experimental
    public @interface SubclassMappings
    Configures the SubclassMappings of several subclasses.

    TIP: When using java 8 or later, you can omit the @SubclassMappings Wrapper annotation and directly specify several @SubclassMapping annotations on one method.

    These two examples are equal.

    
     // before java 8
     @Mapper
     public interface MyMapper {
         @SubclassMappings({
             @SubclassMapping(source = FirstSub.class, target = FirstTargetSub.class),
             @SubclassMapping(source = SecondSub.class, target = SecondTargetSub.class)
         })
         ParentTarget toParentTarget(Parent parent);
     }
     
    
     // java 8 and later
     @Mapper
     public interface MyMapper {
         @SubclassMapping(source = First.class, target = FirstTargetSub.class),
         @SubclassMapping(source = SecondSub.class, target = SecondTargetSub.class)
         ParentTarget toParentTarget(Parent parent);
     }
     
    Since:
    1.5
    Author:
    Ben Zegveld
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      SubclassMapping[] value  
    • Element Detail