org.springframework.test.util

Class MetaAnnotationUtils.AnnotationDescriptor<T extends java.lang.annotation.Annotation>

  • java.lang.Object
    • org.springframework.test.util.MetaAnnotationUtils.AnnotationDescriptor<T>
  • Type Parameters:
    T - the annotation type
    Direct Known Subclasses:
    MetaAnnotationUtils.UntypedAnnotationDescriptor
    Enclosing class:
    MetaAnnotationUtils


    public static class MetaAnnotationUtils.AnnotationDescriptor<T extends java.lang.annotation.Annotation>
    extends java.lang.Object
    Descriptor for an 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.

    • 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 the UserRepositoryTests class, then the properties of the AnnotationDescriptor 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 { }
     
    • Constructor Detail

      • AnnotationDescriptor

        public AnnotationDescriptor(java.lang.Class<?> rootDeclaringClass,
                                    T annotation)
      • AnnotationDescriptor

        public AnnotationDescriptor(java.lang.Class<?> rootDeclaringClass,
                                    java.lang.Class<?> declaringClass,
                                    @Nullable
                                    java.lang.annotation.Annotation composedAnnotation,
                                    T annotation)