类 MetaAnnotationUtils

    • 方法详细资料

      • findAnnotationDescriptor

        public static <T extends AnnotationMetaAnnotationUtils.AnnotationDescriptor<T> findAnnotationDescriptor​(Class<?> clazz,
                                                                                                                  Class<T> annotationType)
        Find the MetaAnnotationUtils.AnnotationDescriptor for the supplied annotationType on the supplied Class, traversing its annotations, interfaces, and superclasses if no annotation can be found on the given class itself.

        This method explicitly handles class-level annotations which are not declared as inheritedas well as meta-annotations.

        The algorithm operates as follows:

        1. Search for the annotation on the given class and return a corresponding AnnotationDescriptor if found.
        2. Recursively search through all annotations that the given class declares.
        3. Recursively search through all interfaces implemented by the given class.
        4. Recursively search through the superclass hierarchy of the given class.

        In this context, the term recursively means that the search process continues by returning to step #1 with the current annotation, interface, or superclass as the class to look for annotations on.

        参数:
        clazz - the class to look for annotations on
        annotationType - the type of annotation to look for
        返回:
        the corresponding annotation descriptor if the annotation was found; otherwise null
        另请参阅:
        AnnotationUtils.findAnnotationDeclaringClass(Class, Class), findAnnotationDescriptorForTypes(Class, Class...)
      • findAnnotationDescriptorForTypes

        public static MetaAnnotationUtils.UntypedAnnotationDescriptor findAnnotationDescriptorForTypes​(Class<?> clazz,
                                                                                                       Class<? extends Annotation>... annotationTypes)
        Find the MetaAnnotationUtils.UntypedAnnotationDescriptor for the first Class in the inheritance hierarchy of the specified clazz (including the specified clazz itself) which declares at least one of the specified annotationTypes.

        This method traverses the annotations, interfaces, and superclasses of the specified clazz if no annotation can be found on the given class itself.

        This method explicitly handles class-level annotations which are not declared as inheritedas well as meta-annotations.

        The algorithm operates as follows:

        1. Search for a local declaration of one of the annotation types on the given class and return a corresponding UntypedAnnotationDescriptor if found.
        2. Recursively search through all annotations that the given class declares.
        3. Recursively search through all interfaces implemented by the given class.
        4. Recursively search through the superclass hierarchy of the given class.

        In this context, the term recursively means that the search process continues by returning to step #1 with the current annotation, interface, or superclass as the class to look for annotations on.

        参数:
        clazz - the class to look for annotations on
        annotationTypes - the types of annotations to look for
        返回:
        the corresponding annotation descriptor if one of the annotations was found; otherwise null
        另请参阅:
        AnnotationUtils.findAnnotationDeclaringClassForTypes(java.util.List, Class), findAnnotationDescriptor(Class, Class)