Interface AnnotationMapping<T extends Annotation>

Type Parameters:
T - 注解类型
All Superinterfaces:
Annotation
All Known Implementing Classes:
GenericAnnotationMapping, ResolvedAnnotationMapping

public interface AnnotationMapping<T extends Annotation> extends Annotation
用于增强注解的包装器
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default Class<? extends Annotation>
    获取注解类型
    获取注解对象
    获取注解原始属性
    <R> R
    getAttributeValue(String attributeName, Class<R> attributeType)
    获取属性值
    根据当前映射对象,通过动态代理生成一个类型与被包装注解对象一致地合成注解,该注解相对原生注解: 支持同注解内通过Alias构建的别名机制; 支持子注解对元注解的同名同类型属性覆盖机制; 当isResolved()false时,则该方法应当被包装的原始注解对象, 即返回值应当与getAnnotation()相同。
    <R> R
    getResolvedAttributeValue(String attributeName, Class<R> attributeType)
    获取解析后的属性值
    boolean
    当前注解是否存在被解析的属性,当该值为false时, 通过getResolvedAttributeValue获得的值皆为注解的原始属性值, 通过getResolvedAnnotation()获得注解对象为原始的注解对象。
    boolean
    当前注解是否为根注解

    Methods inherited from interface java.lang.annotation.Annotation

    equals, hashCode, toString
  • Method Details

    • isRoot

      boolean isRoot()
      当前注解是否为根注解
      Returns:
      是否
    • getAnnotation

      T getAnnotation()
      获取注解对象
      Returns:
      注解对象
    • getResolvedAnnotation

      T getResolvedAnnotation()
      根据当前映射对象,通过动态代理生成一个类型与被包装注解对象一致地合成注解,该注解相对原生注解:
      • 支持同注解内通过Alias构建的别名机制;
      • 支持子注解对元注解的同名同类型属性覆盖机制;
      isResolved()false时,则该方法应当被包装的原始注解对象, 即返回值应当与getAnnotation()相同。
      Returns:
      所需的注解,若isResolved()false则返回的是原始的注解对象
    • annotationType

      default Class<? extends Annotation> annotationType()
      获取注解类型
      Specified by:
      annotationType in interface Annotation
      Returns:
      注解类型
    • isResolved

      boolean isResolved()
      当前注解是否存在被解析的属性,当该值为false时, 通过getResolvedAttributeValue获得的值皆为注解的原始属性值, 通过getResolvedAnnotation()获得注解对象为原始的注解对象。
      Returns:
      是否
    • getAttributes

      Method[] getAttributes()
      获取注解原始属性
      Returns:
      注解属性
    • getAttributeValue

      <R> R getAttributeValue(String attributeName, Class<R> attributeType)
      获取属性值
      Type Parameters:
      R - 返回值类型
      Parameters:
      attributeName - 属性名称
      attributeType - 属性类型
      Returns:
      属性值
    • getResolvedAttributeValue

      <R> R getResolvedAttributeValue(String attributeName, Class<R> attributeType)
      获取解析后的属性值
      Type Parameters:
      R - 返回值类型
      Parameters:
      attributeName - 属性名称
      attributeType - 属性类型
      Returns:
      属性值