类 MetaAnnotationUtils.AnnotationDescriptor<T extends Annotation>
- java.lang.Object
- org.springframework.test.util.MetaAnnotationUtils.AnnotationDescriptor<T>
public static class MetaAnnotationUtils.AnnotationDescriptor<T extends Annotation> extends Object
Descriptor for anAnnotation
, 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 theTransactionalTests
class, then the properties of theAnnotationDescriptor
would be as follows.- rootDeclaringClass:
TransactionalTests
class object - declaringClass:
TransactionalTests
class object - composedAnnotation:
null
- annotation: instance of the
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 theUserRepositoryTests
class, then the properties of theAnnotationDescriptor
would be as follows.- rootDeclaringClass:
UserRepositoryTests
class object - declaringClass:
RepositoryTests
class object - composedAnnotation: instance of the
RepositoryTests
annotation - annotation: instance of the
Transactional
annotation
@Transactional @ContextConfiguration({"/test-datasource.xml", "/repository-config.xml"}) @Retention(RetentionPolicy.RUNTIME) public @interface RepositoryTests { } @RepositoryTests public class UserRepositoryTests { }
- rootDeclaringClass:
构造器概要
构造器 构造器 说明 AnnotationDescriptor(Class<?> rootDeclaringClass, Class<?> declaringClass, Annotation composedAnnotation, T annotation)
AnnotationDescriptor(Class<?> rootDeclaringClass, T annotation)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 T
getAnnotation()
AnnotationAttributes
getAnnotationAttributes()
Class<? extends Annotation>
getAnnotationType()
Annotation
getComposedAnnotation()
Class<? extends Annotation>
getComposedAnnotationType()
Class<?>
getDeclaringClass()
Class<?>
getRootDeclaringClass()
T
synthesizeAnnotation()
Synthesize the mergedAnnotationAttributes
in this descriptor back into an annotation of the target annotation type.String
toString()
Provide a textual representation of thisAnnotationDescriptor
.
构造器详细资料
AnnotationDescriptor
public AnnotationDescriptor(Class<?> rootDeclaringClass, T annotation)
AnnotationDescriptor
public AnnotationDescriptor(Class<?> rootDeclaringClass, Class<?> declaringClass, Annotation composedAnnotation, T annotation)
方法详细资料
getRootDeclaringClass
public Class<?> getRootDeclaringClass()
getDeclaringClass
public Class<?> getDeclaringClass()
getAnnotation
public T getAnnotation()
synthesizeAnnotation
public T synthesizeAnnotation()
Synthesize the mergedAnnotationAttributes
in this descriptor back into an annotation of the target annotation type.
getAnnotationType
public Class<? extends Annotation> getAnnotationType()
getAnnotationAttributes
public AnnotationAttributes getAnnotationAttributes()
getComposedAnnotation
public Annotation getComposedAnnotation()
getComposedAnnotationType
public Class<? extends Annotation> getComposedAnnotationType()