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

hasAnnotation

open static fun hasAnnotation(element: AnnotatedElement, annotationType: Class<out Annotation>): Boolean

Determine if an annotation of the specified annotationType is available on the supplied AnnotatedElement or within the annotation hierarchy above the specified element.

If this method returns true, then #findMergedAnnotationAttributes will return a non-null value.

This method follows find semantics as described in the AnnotatedElementUtils.

Parameters

element - the annotated element

annotationType - the annotation type to find

Return
true if a matching annotation is present

Since
4.3

See Also
#isAnnotated(AnnotatedElement, Class)