Skip to content

io microsphere spring core annotation AnnotationUtils

github-actions[bot] edited this page Jun 18, 2026 · 18 revisions

AnnotationUtils

Type: Class | Module: microsphere-spring-context | Package: io.microsphere.spring.core.annotation | Since: 1.0.0

Source: microsphere-spring-context/src/main/java/io/microsphere/spring/core/annotation/AnnotationUtils.java

Overview

Annotation Utilities

Declaration

public abstract class AnnotationUtils

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.27-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-spring-context</artifactId>
    <version>${microsphere-spring.version}</version>
</dependency>

Tip: Use the BOM (microsphere-spring-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.spring.core.annotation.AnnotationUtils;

API Reference

Public Methods

Method Description
isPresent Is specified Annotation present on Method's declaring class or parameters or itself.
getAttribute Find specified Annotation type maps from Method
getAttribute Get the attribute value
getAttribute Get the attribute value the will
getAttribute Get the attribute value with default value
getRequiredAttribute Get the required attribute value
getAnnotationAttributes Get the AnnotationAttributes
getAnnotationAttributes Get the AnnotationAttributes
getAnnotationAttributes Get the AnnotationAttributes
getAnnotationAttributes Get the AnnotationAttributes
getAnnotationAttributes Get the AnnotationAttributes
getAnnotationAttributes Get the AnnotationAttributes
getAnnotationAttributes Get the AnnotationAttributes
getAnnotationAttributes Get the AnnotationAttributes, if the argument tryMergedAnnotation is true,
getAnnotationAttributes Get the AnnotationAttributes, if the argument tryMergedAnnotation is true,
getAnnotationAttributes Get an instance of AnnotationAttributes from AnnotationMetadata with the specified class name of
getAnnotationAttributes Get an instance of AnnotationAttributes from AnnotationMetadata with the specified class name of
tryGetMergedAnnotation Try to get the merged Annotation annotation
tryGetMergedAnnotation Try to get the merged Annotation annotation
tryGetMergedAnnotationAttributes Try to get AnnotationAttributes the annotation attributes after merging and resolving the placeholders

Method Details

isPresent

public static <A extends Annotation> boolean isPresent(Method method, Class<A> annotationClass)

Is specified Annotation present on Method's declaring class or parameters or itself.

getAttribute

public static <T> T getAttribute(Annotation annotation, String attributeName)

Find specified Annotation type maps from Method

getAnnotationAttributes

public static AnnotationAttributes getAnnotationAttributes(AnnotatedElement annotatedElement,
                                                               Class<? extends Annotation> annotationType,
                                                               PropertyResolver propertyResolver,
                                                               boolean ignoreDefaultValue,
                                                               boolean tryMergedAnnotation,
                                                               String... ignoreAttributeNames)

Get the AnnotationAttributes, if the argument tryMergedAnnotation is true, the AnnotationAttributes will be got from #tryGetMergedAnnotationAttributes(AnnotatedElement, Class, PropertyResolver, boolean, String...) merged annotation first, if failed, and then to get from #getAnnotationAttributes(AnnotatedElement, Class, PropertyResolver, boolean, boolean, String...) normal one

getAnnotationAttributes

public static AnnotationAttributes getAnnotationAttributes(AnnotatedElement annotatedElement,
                                                               Class<? extends Annotation> annotationType,
                                                               PropertyResolver propertyResolver,
                                                               boolean classValuesAsString,
                                                               boolean nestedAnnotationsAsMap,
                                                               boolean ignoreDefaultValue,
                                                               boolean tryMergedAnnotation,
                                                               String... ignoreAttributeNames)

Get the AnnotationAttributes, if the argument tryMergedAnnotation is true, the AnnotationAttributes will be got from #tryGetMergedAnnotationAttributes(AnnotatedElement, Class, PropertyResolver, boolean, String...) merged annotation first, if failed, and then to get from #getAnnotationAttributes(AnnotatedElement, Class, PropertyResolver, boolean, boolean, String...) normal one

getAnnotationAttributes

public static AnnotationAttributes getAnnotationAttributes(AnnotationMetadata metadata, Class<? extends Annotation> annotationType)

Get an instance of AnnotationAttributes from AnnotationMetadata with the specified class name of Annotation annotation.

getAnnotationAttributes

public static AnnotationAttributes getAnnotationAttributes(AnnotationMetadata metadata, String annotationClassName)

Get an instance of AnnotationAttributes from AnnotationMetadata with the specified class name of Annotation annotation.

tryGetMergedAnnotation

public static Annotation tryGetMergedAnnotation(AnnotatedElement annotatedElement,
                                                    Class<? extends Annotation> annotationType)

Try to get the merged Annotation annotation

tryGetMergedAnnotation

public static Annotation tryGetMergedAnnotation(AnnotatedElement annotatedElement,
                                                    Class<? extends Annotation> annotationType,
                                                    boolean classValuesAsString,
                                                    boolean nestedAnnotationsAsMap)

Try to get the merged Annotation annotation

tryGetMergedAnnotationAttributes

public static AnnotationAttributes tryGetMergedAnnotationAttributes(AnnotatedElement annotatedElement,
                                                                        Class<? extends Annotation> annotationType,
                                                                        PropertyResolver propertyResolver,
                                                                        boolean ignoreDefaultValue,
                                                                        String... ignoreAttributeNames)

Try to get AnnotationAttributes the annotation attributes after merging and resolving the placeholders

See Also

  • Annotation

This documentation was auto-generated from the source code of microsphere-spring.

Home

spring-context

spring-guice

spring-jdbc

spring-test

spring-web

spring-webflux

spring-webmvc

Clone this wiki locally