spring-framework / org.springframework.core.annotation / AnnotatedElementUtils / findMergedAnnotation

findMergedAnnotation

@Nullable open static fun <A : Annotation> findMergedAnnotation(element: AnnotatedElement, annotationType: Class<A>): A

Find the first annotation of the specified annotationType within the annotation hierarchy above the supplied element, merge that annotation's attributes with matching attributes from annotations in lower levels of the annotation hierarchy, and synthesize the result back into an annotation of the specified annotationType.

AliasFor semantics are fully supported, both within a single annotation and within the annotation hierarchy.

This method follows find semantics as described in the AnnotatedElementUtils.

Parameters

element - the annotated element

annotationType - the annotation type to find

Return
the merged, synthesized Annotation, or null if not found

Since
4.2

See Also
#findAllMergedAnnotations(AnnotatedElement, Class)#findMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)#getMergedAnnotationAttributes(AnnotatedElement, Class)