Package org.mapstruct

Annotation Type 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
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    Used in combination with AnnotateWith to configure the annotation elements.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Class<? extends Annotation>
    The annotation class that needs to be added.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The annotation elements that are to be applied to the annotation that should be added.
  • Element Details

    • value

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

      The annotation elements that are to be applied to the annotation that should be added.
      Returns:
      the annotation elements that are to be applied to this annotation.
      Default:
      {}