T - the annotation typepublic static class MetaAnnotationUtils.AnnotationDescriptor<T extends Annotation> extends 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 objectnullTransactional 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 { }
| Constructor and Description |
|---|
AnnotationDescriptor(Class<?> rootDeclaringClass,
Class<?> declaringClass,
Annotation composedAnnotation,
T annotation) |
AnnotationDescriptor(Class<?> rootDeclaringClass,
T annotation) |
| Modifier and Type | Method and Description |
|---|---|
Set<T> |
findAllLocalMergedAnnotations()
Find all annotations of the specified
annotation type that are present or
meta-present on the root declaring
class of this descriptor.
|
T |
getAnnotation() |
AnnotationAttributes |
getAnnotationAttributes() |
Class<? extends Annotation> |
getAnnotationType() |
Annotation |
getComposedAnnotation() |
Class<? extends Annotation> |
getComposedAnnotationType() |
Class<?> |
getDeclaringClass() |
Class<?> |
getRootDeclaringClass() |
MetaAnnotationUtils.AnnotationDescriptor<T> |
next()
Find the next
MetaAnnotationUtils.AnnotationDescriptor for the specified
annotation type in the hierarchy
above the root declaring class
of this descriptor. |
T |
synthesizeAnnotation()
Synthesize the merged
AnnotationAttributes
in this descriptor back into an annotation of the target
annotation type. |
String |
toString()
Provide a textual representation of this
AnnotationDescriptor. |
public AnnotationDescriptor(Class<?> rootDeclaringClass, Class<?> declaringClass, @Nullable Annotation composedAnnotation, T annotation)
public Class<?> getRootDeclaringClass()
public Class<?> getDeclaringClass()
public T getAnnotation()
public T synthesizeAnnotation()
AnnotationAttributes
in this descriptor back into an annotation of the target
annotation type.public Class<? extends Annotation> getAnnotationType()
public AnnotationAttributes getAnnotationAttributes()
@Nullable public Annotation getComposedAnnotation()
@Nullable public Class<? extends Annotation> getComposedAnnotationType()
@Nullable public MetaAnnotationUtils.AnnotationDescriptor<T> next()
MetaAnnotationUtils.AnnotationDescriptor for the specified
annotation type in the hierarchy
above the root declaring class
of this descriptor.
If a corresponding annotation is found in the superclass hierarchy of the root declaring class, that will be returned. Otherwise, an attempt will be made to find a corresponding annotation in the enclosing class hierarchy of the root declaring class if appropriate.
nullpublic Set<T> findAllLocalMergedAnnotations()
Annotations found,
or an empty set if none were found