Class AnnotationMetadata
java.lang.Object
cloud.opencode.base.classloader.metadata.AnnotationMetadata
Annotation Metadata - Immutable annotation information
注解元数据 - 不可变的注解信息
Represents annotation metadata read from class files without loading the class.
表示从类文件读取的注解元数据,无需加载类。
Features | 主要功能:
- Annotation type information - 注解类型信息
- Annotation attributes access - 注解属性访问
- Runtime visibility check - 运行时可见性检查
Usage Examples | 使用示例:
AnnotationMetadata annotation = classMetadata.getAnnotation("Service").orElseThrow();
String value = annotation.getAttribute("value", String.class).orElse("");
boolean isRuntime = annotation.isRuntimeVisible();
Security | 安全性:
- Thread-safe: Yes (immutable) - 线程安全: 是 (不可变)
- Null-safe: Yes - 空值安全: 是
- Since:
- JDK 25, opencode-base-classloader V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAnnotationMetadata(String annotationType, Map<String, Object> attributes, boolean runtimeVisible) Create annotation metadata 创建注解元数据 -
Method Summary
Modifier and TypeMethodDescriptionGet annotation type name 获取注解类型名称Get annotation attributes 获取注解属性boolean<T> Optional<T> getAttribute(String name, Class<T> type) Get attribute value with type 获取指定类型的属性值<T> TgetAttribute(String name, Class<T> type, T defaultValue) Get attribute value with type and default 获取指定类型的属性值,带默认值Get all attribute names 获取所有属性名Get simple type name (without package) 获取简单类型名(不含包名)Get 'value' attribute as String 获取 'value' 属性作为字符串getValue()Get 'value' attribute 获取 'value' 属性booleanhasAttribute(String name) Check if attribute exists 检查属性是否存在inthashCode()booleanCheck if annotation is visible at runtime 检查注解是否运行时可见toString()
-
Constructor Details
-
AnnotationMetadata
-
-
Method Details
-
annotationType
Get annotation type name 获取注解类型名称- Returns:
- annotation type name | 注解类型名称
-
attributes
-
isRuntimeVisible
public boolean isRuntimeVisible()Check if annotation is visible at runtime 检查注解是否运行时可见- Returns:
- true if runtime visible | 运行时可见返回 true
-
getAttribute
-
getAttribute
Get attribute value with type and default 获取指定类型的属性值,带默认值- Type Parameters:
T- type parameter | 类型参数- Parameters:
name- attribute name | 属性名type- expected type | 期望类型defaultValue- default value | 默认值- Returns:
- attribute value or default | 属性值或默认值
-
getValue
-
getStringValue
-
hasAttribute
Check if attribute exists 检查属性是否存在- Parameters:
name- attribute name | 属性名- Returns:
- true if exists | 存在返回 true
-
getAttributeNames
-
getSimpleName
Get simple type name (without package) 获取简单类型名(不含包名)- Returns:
- simple name | 简单名称
-
equals
-
hashCode
-
toString
-