Package org.mapstruct

Annotation Type AnnotateWith


  • @Repeatable(AnnotateWiths.class)
    @Retention(CLASS)
    @Target({TYPE,METHOD,ANNOTATION_TYPE})
    public @interface AnnotateWith
    This can be used to have mapstruct generate additional annotations on classes/methods.

    Examples based on the spring framework annotations.

    Marking a class as `Lazy`:
    
     @AnnotateWith( value = Lazy.class )
     @Mapper
     public interface FooMapper {
         // mapper code
     }
     
    The following code would be generated:
    
     @Lazy
     public class FooMapperImpl implements FooMapper {
         // mapper code
     }
     
    Setting the profile on the generated implementation:
    
     @AnnotateWith( value = Profile.class, elements = @AnnotateWith.Element( strings = "prod" ) )
     @Mapper
     public interface FooMapper {
         // mapper code
     }
     
    The following code would be generated:
    
     @Profile( value = "prod" )
     public class FooMapperImpl implements FooMapper {
         // mapper code
     }
     
    Since:
    1.6
    Author:
    Ben Zegveld
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      Class<? extends Annotation> value  
    • Element Detail

      • value

        Class<? extends Annotation> value
        Returns:
        the annotation class that needs to be added.
      • elements

        AnnotateWith.Element[] elements
        Returns:
        the annotation elements that are to be applied to this annotation.
        Default:
        {}