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

getMergedAnnotationAttributes

@Nullable open static fun getMergedAnnotationAttributes(element: AnnotatedElement, annotationType: Class<out Annotation>): AnnotationAttributes

Get the first annotation of the specified annotationType within the annotation hierarchy above the supplied element and merge that annotation's attributes with matching attributes from annotations in lower levels of the annotation hierarchy.

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

This method delegates to #getMergedAnnotationAttributes(AnnotatedElement, String).

Parameters

element - the annotated element

annotationType - the annotation type to find

Return
the merged AnnotationAttributes, or null if not found

Since
4.2

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

@Nullable open static fun getMergedAnnotationAttributes(element: AnnotatedElement, annotationName: String): AnnotationAttributes

Get the first annotation of the specified annotationName within the annotation hierarchy above the supplied element and merge that annotation's attributes with matching attributes from annotations in lower levels of the annotation hierarchy.

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

This method delegates to #getMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean), supplying false for classValuesAsString and nestedAnnotationsAsMap.

Parameters

element - the annotated element

annotationName - the fully qualified class name of the annotation type to find

Return
the merged AnnotationAttributes, or null if not found

Since
4.2

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

@Nullable open static fun getMergedAnnotationAttributes(element: AnnotatedElement, annotationName: String, classValuesAsString: Boolean, nestedAnnotationsAsMap: Boolean): AnnotationAttributes

Get the first annotation of the specified annotationName within the annotation hierarchy above the supplied element and merge that annotation's attributes with matching attributes from annotations in lower levels of the annotation hierarchy.

Attributes from lower levels in the annotation hierarchy override attributes of the same name from higher levels, and AliasFor semantics are fully supported, both within a single annotation and within the annotation hierarchy.

In contrast to #getAllAnnotationAttributes, the search algorithm used by this method will stop searching the annotation hierarchy once the first annotation of the specified annotationName has been found. As a consequence, additional annotations of the specified annotationName will be ignored.

This method follows get semantics as described in the AnnotatedElementUtils.

Parameters

element - the annotated element

annotationName - the fully qualified class name of the annotation type to find

classValuesAsString - whether to convert Class references into Strings or to preserve them as Class references

nestedAnnotationsAsMap - whether to convert nested Annotation instances into AnnotationAttributes maps or to preserve them as Annotation instances

Return
the merged AnnotationAttributes, or null if not found

Since
4.2

See Also
#findMergedAnnotation(AnnotatedElement, Class)#findMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)#getAllAnnotationAttributes(AnnotatedElement, String, boolean, boolean)