Class TestContextAnnotationUtils.AnnotationDescriptor<T extends Annotation>

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

public static class TestContextAnnotationUtils.AnnotationDescriptor<T extends Annotation> extends Object
Descriptor for an Annotation, including the class on which the annotation is declared as well as the merged annotation instance.

If the annotation is used as a meta-annotation, the root declaring class is not directly annotated with the annotation but rather indirectly via a 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
  • 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
  • annotation: instance of the Transactional annotation

 @Transactional
 @ContextConfiguration({"/test-datasource.xml", "/repository-config.xml"})
 @Retention(RetentionPolicy.RUNTIME)
 public @interface RepositoryTests { }

 @RepositoryTests
 public class UserRepositoryTests { }
 
  • Method Details

    • getRootDeclaringClass

      public Class<?> getRootDeclaringClass()
    • getDeclaringClass

      public Class<?> getDeclaringClass()
    • getAnnotation

      public T getAnnotation()
      Get the merged annotation for this descriptor.
    • next

      Find the next TestContextAnnotationUtils.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.

      Returns:
      the next corresponding annotation descriptor if the annotation was found; otherwise null
    • findAllLocalMergedAnnotations

      public 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 or on any interfaces that the root declaring class implements.
      Returns:
      the set of all merged, synthesized Annotations found, or an empty set if none were found
    • toString

      public String toString()
      Provide a textual representation of this AnnotationDescriptor.
      Overrides:
      toString in class Object