T
- the annotation typepublic static class MetaAnnotationUtils.AnnotationDescriptor<T extends java.lang.annotation.Annotation>
extends java.lang.Object
Annotation
, including the class on which the annotation is declared
as well as the actual annotation instance.
If the annotation is used as a meta-annotation, the descriptor also includes the composed annotation on which the annotation is present. In such cases, the root declaring class is not directly annotated with the annotation but rather indirectly via the composed annotation.
Given the following example, if we are searching for the @Transactional
annotation on the TransactionalTests
class, then the
properties of the AnnotationDescriptor
would be as follows.
TransactionalTests
class objectTransactionalTests
class objectnull
Transactional
annotation@Transactional @ContextConfiguration({"/test-datasource.xml", "/repository-config.xml"}) public class TransactionalTests { }
Given the following example, if we are searching for the @Transactional
annotation on the UserRepositoryTests
class, then the
properties of the AnnotationDescriptor
would be as follows.
UserRepositoryTests
class objectRepositoryTests
class objectRepositoryTests
annotationTransactional
annotation@Transactional @ContextConfiguration({"/test-datasource.xml", "/repository-config.xml"}) @Retention(RetentionPolicy.RUNTIME) public @interface RepositoryTests { } @RepositoryTests public class UserRepositoryTests { }
Modifier and Type | Field and Description |
---|---|
private T |
annotation |
private AnnotationAttributes |
annotationAttributes |
private java.lang.annotation.Annotation |
composedAnnotation |
private java.lang.Class<?> |
declaringClass |
private java.lang.Class<?> |
rootDeclaringClass |
Constructor and Description |
---|
AnnotationDescriptor(java.lang.Class<?> rootDeclaringClass,
java.lang.Class<?> declaringClass,
java.lang.annotation.Annotation composedAnnotation,
T annotation) |
AnnotationDescriptor(java.lang.Class<?> rootDeclaringClass,
T annotation) |
Modifier and Type | Method and Description |
---|---|
T |
getAnnotation() |
AnnotationAttributes |
getAnnotationAttributes() |
java.lang.Class<? extends java.lang.annotation.Annotation> |
getAnnotationType() |
java.lang.annotation.Annotation |
getComposedAnnotation() |
java.lang.Class<? extends java.lang.annotation.Annotation> |
getComposedAnnotationType() |
java.lang.Class<?> |
getDeclaringClass() |
java.lang.Class<?> |
getRootDeclaringClass() |
T |
synthesizeAnnotation()
Synthesize the merged
AnnotationAttributes
in this descriptor back into an annotation of the target
annotation type. |
java.lang.String |
toString()
Provide a textual representation of this
AnnotationDescriptor . |
private final java.lang.Class<?> rootDeclaringClass
private final java.lang.Class<?> declaringClass
@Nullable private final java.lang.annotation.Annotation composedAnnotation
private final T extends java.lang.annotation.Annotation annotation
private final AnnotationAttributes annotationAttributes
public AnnotationDescriptor(java.lang.Class<?> rootDeclaringClass, T annotation)
public java.lang.Class<?> getRootDeclaringClass()
public java.lang.Class<?> getDeclaringClass()
public T getAnnotation()
public T synthesizeAnnotation()
AnnotationAttributes
in this descriptor back into an annotation of the target
annotation type.public java.lang.Class<? extends java.lang.annotation.Annotation> getAnnotationType()
public AnnotationAttributes getAnnotationAttributes()
@Nullable public java.lang.annotation.Annotation getComposedAnnotation()
@Nullable public java.lang.Class<? extends java.lang.annotation.Annotation> getComposedAnnotationType()
public java.lang.String toString()
AnnotationDescriptor
.toString
in class java.lang.Object