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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceUsed in combination withAnnotateWithto configure the annotation elements. -
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionClass<? extends Annotation> The annotation class that needs to be added. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe annotation elements that are to be applied to the annotation that should be added.
-
Element Details
-
value
Class<? extends Annotation> valueThe annotation class that needs to be added.- Returns:
- the annotation class that needs to be added.
-
elements
AnnotateWith.Element[] elementsThe 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:
{}
-