- All Known Subinterfaces:
AbstractMethodCreator,AnonymousClassCreator,ClassCreator,ConstructorCreator,ExecutableCreator,FieldCreator,InstanceExecutableCreator,InstanceFieldCreator,InstanceMethodCreator,InterfaceCreator,MemberCreator,MethodCreator,ModifiableCreator,ParamCreator,StaticExecutableCreator,StaticFieldCreator,StaticMethodCreator,TypeCreator,TypeParameterCreator
public sealed interface AnnotatableCreator
permits ModifiableCreator, TypeParameterCreator (not exhaustive)
An element that can be annotated.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <A extends Annotation>
voidaddAnnotation(A annotation) Add the given annotation object to this creator.default voidaddAnnotation(Class<? extends Annotation> annotationClass) Add an annotation with no elements.<A extends Annotation>
voidaddAnnotation(Class<A> annotationClass, Consumer<AnnotationCreator<A>> builder) Add an annotation with elements provided by givenbuilder.voidaddAnnotation(ClassDesc annotationClass, RetentionPolicy retentionPolicy, Consumer<AnnotationCreator<Annotation>> builder) Add an annotation of given class with given retention policy and with elements provided by givenbuilder.
-
Method Details
-
addAnnotation
Add the given annotation object to this creator.- Type Parameters:
A- the annotation type- Parameters:
annotation- the annotation object (must not benull)
-
addAnnotation
Add an annotation with no elements. IfannotationClasshas noRetentionannotation,RetentionPolicy.RUNTIMEis assumed. This is the most commonly used value, even thoughCLASSis the specified default.If the annotation is repeatable, and adding this annotation would cause there to be more than one instance of the given annotation on this element, then the existing annotation and the given annotation are automatically wrapped in the container annotation.
- Parameters:
annotationClass- the class of the annotation (must not benull)- Throws:
IllegalArgumentException- if the annotation is not repeatable and appears more than once on this element
-
addAnnotation
<A extends Annotation> void addAnnotation(Class<A> annotationClass, Consumer<AnnotationCreator<A>> builder) Add an annotation with elements provided by givenbuilder. IfannotationClasshas noRetentionannotation,RetentionPolicy.RUNTIMEis assumed. This is the most commonly used value, even thoughCLASSis the specified default.If the annotation is repeatable, and adding this annotation would cause there to be more than one instance of the given annotation on this element, then the existing annotation and the given annotation are automatically wrapped in the container annotation.
- Type Parameters:
A- the annotation type- Parameters:
annotationClass- the class of the annotation (must not benull)builder- the builder which adds annotation values (must not benull)- Throws:
IllegalArgumentException- if the annotation is not repeatable and appears more than once on this element
-
addAnnotation
void addAnnotation(ClassDesc annotationClass, RetentionPolicy retentionPolicy, Consumer<AnnotationCreator<Annotation>> builder) Add an annotation of given class with given retention policy and with elements provided by givenbuilder.If the annotation is repeatable, then it is the responsibility of the caller to ensure that the repeated values are appropriately wrapped in the container annotation if necessary.
- Parameters:
annotationClass- the class of the annotation (must not benull)retentionPolicy- the retention policy of the annotation (must not benull)builder- the builder which adds annotation values (must not benull)- Throws:
IllegalArgumentException- if the annotation appears more than once on this element
-