Class MethodMetadata
java.lang.Object
cloud.opencode.base.classloader.metadata.MethodMetadata
Method Metadata - Immutable method information
方法元数据 - 不可变的方法信息
Represents method metadata read from class files without loading the class.
表示从类文件读取的方法元数据,无需加载类。
Features | 主要功能:
- Method signature information - 方法签名信息
- Parameter types and names - 参数类型和名称
- Modifier information - 修饰符信息
- Annotation information - 注解信息
Usage Examples | 使用示例:
MethodMetadata method = classMetadata.methods().get(0);
String name = method.methodName();
String returnType = method.returnType();
boolean isGetter = method.isGetter();
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
ConstructorsConstructorDescriptionMethodMetadata(String methodName, String returnType, List<String> parameterTypes, List<String> parameterNames, List<String> exceptionTypes, int modifiers, boolean isSynthetic, boolean isBridge, boolean isDefault, List<AnnotationMetadata> annotations, List<List<AnnotationMetadata>> parameterAnnotations) Create method metadata 创建方法元数据MethodMetadata(String methodName, String returnType, List<String> parameterTypes, List<String> parameterNames, List<String> exceptionTypes, int modifiers, boolean isSynthetic, boolean isBridge, boolean isDefault, List<AnnotationMetadata> annotations, List<List<AnnotationMetadata>> parameterAnnotations, String genericSignature, String genericReturnType, List<String> genericParameterTypes) Create method metadata with generic type information 创建带有泛型类型信息的方法元数据 -
Method Summary
Modifier and TypeMethodDescriptionGet annotations 获取注解booleanGet exception types 获取异常类型getAnnotation(String annotationClassName) Get specified annotation 获取指定注解Get generic parameter types 获取泛型参数类型列表Get generic return type (e.g.Get generic signature of the method 获取方法的泛型签名Get method signature 获取方法签名booleanhasAnnotation(String annotationClassName) Check if has specified annotation 检查是否有指定注解inthashCode()booleanCheck if no parameters 检查是否无参数booleanCheck if abstract 检查是否为抽象方法booleanisBridge()Check if bridge method 检查是否为桥接方法booleanCheck if is constructor 检查是否为构造方法booleanCheck if default method 检查是否为默认方法booleanisFinal()Check if final 检查是否为 final 方法booleanisGetter()Check if is getter method 检查是否为 getter 方法booleanCheck if private 检查是否为 private 方法booleanCheck if protected 检查是否为 protected 方法booleanisPublic()Check if public 检查是否为 public 方法booleanisSetter()Check if is setter method 检查是否为 setter 方法booleanisStatic()Check if static 检查是否为静态方法booleanCheck if is static initializer 检查是否为静态初始化块booleanCheck if synthetic 检查是否为合成方法Get method name 获取方法名intGet modifiers 获取修饰符Get parameter annotations 获取参数注解intGet parameter count 获取参数数量Get parameter names 获取参数名称Get parameter types 获取参数类型Get return type 获取返回类型toString()
-
Constructor Details
-
MethodMetadata
public MethodMetadata(String methodName, String returnType, List<String> parameterTypes, List<String> parameterNames, List<String> exceptionTypes, int modifiers, boolean isSynthetic, boolean isBridge, boolean isDefault, List<AnnotationMetadata> annotations, List<List<AnnotationMetadata>> parameterAnnotations) Create method metadata 创建方法元数据- Parameters:
methodName- method name | 方法名returnType- return type | 返回类型parameterTypes- parameter types | 参数类型parameterNames- parameter names | 参数名称exceptionTypes- exception types | 异常类型modifiers- modifier flags | 修饰符标志isSynthetic- is synthetic | 是否合成isBridge- is bridge method | 是否桥接方法isDefault- is default method | 是否默认方法annotations- method annotations | 方法注解parameterAnnotations- parameter annotations | 参数注解
-
MethodMetadata
public MethodMetadata(String methodName, String returnType, List<String> parameterTypes, List<String> parameterNames, List<String> exceptionTypes, int modifiers, boolean isSynthetic, boolean isBridge, boolean isDefault, List<AnnotationMetadata> annotations, List<List<AnnotationMetadata>> parameterAnnotations, String genericSignature, String genericReturnType, List<String> genericParameterTypes) Create method metadata with generic type information 创建带有泛型类型信息的方法元数据- Parameters:
methodName- method name | 方法名returnType- return type | 返回类型parameterTypes- parameter types | 参数类型parameterNames- parameter names | 参数名称exceptionTypes- exception types | 异常类型modifiers- modifier flags | 修饰符标志isSynthetic- is synthetic | 是否合成isBridge- is bridge method | 是否桥接方法isDefault- is default method | 是否默认方法annotations- method annotations | 方法注解parameterAnnotations- parameter annotations | 参数注解genericSignature- generic signature | 泛型签名genericReturnType- generic return type | 泛型返回类型genericParameterTypes- generic parameter types | 泛型参数类型列表
-
-
Method Details
-
methodName
-
returnType
-
parameterTypes
-
parameterNames
-
exceptionTypes
-
modifiers
public int modifiers()Get modifiers 获取修饰符- Returns:
- modifier flags | 修饰符标志
-
isSynthetic
public boolean isSynthetic()Check if synthetic 检查是否为合成方法- Returns:
- true if synthetic | 是合成方法返回 true
-
isBridge
public boolean isBridge()Check if bridge method 检查是否为桥接方法- Returns:
- true if bridge | 是桥接方法返回 true
-
isDefault
public boolean isDefault()Check if default method 检查是否为默认方法- Returns:
- true if default | 是默认方法返回 true
-
annotations
Get annotations 获取注解- Returns:
- list of annotations | 注解列表
-
parameterAnnotations
Get parameter annotations 获取参数注解- Returns:
- list of parameter annotation lists | 参数注解列表的列表
-
getGenericSignature
Get generic signature of the method 获取方法的泛型签名- Returns:
- generic signature or null if not generic | 泛型签名,非泛型方法返回 null
-
getGenericReturnType
Get generic return type (e.g. "List<String>" instead of "List") 获取泛型返回类型(如 "List<String>" 而非 "List")- Returns:
- generic return type or null | 泛型返回类型或 null
-
getGenericParameterTypes
-
isAbstract
public boolean isAbstract()Check if abstract 检查是否为抽象方法- Returns:
- true if abstract | 是抽象方法返回 true
-
isStatic
public boolean isStatic()Check if static 检查是否为静态方法- Returns:
- true if static | 是静态方法返回 true
-
isFinal
public boolean isFinal()Check if final 检查是否为 final 方法- Returns:
- true if final | 是 final 方法返回 true
-
isPublic
public boolean isPublic()Check if public 检查是否为 public 方法- Returns:
- true if public | 是 public 方法返回 true
-
isPrivate
public boolean isPrivate()Check if private 检查是否为 private 方法- Returns:
- true if private | 是 private 方法返回 true
-
isProtected
public boolean isProtected()Check if protected 检查是否为 protected 方法- Returns:
- true if protected | 是 protected 方法返回 true
-
hasAnnotation
Check if has specified annotation 检查是否有指定注解- Parameters:
annotationClassName- annotation class name | 注解类名- Returns:
- true if has annotation | 有注解返回 true
-
getAnnotation
Get specified annotation 获取指定注解- Parameters:
annotationClassName- annotation class name | 注解类名- Returns:
- optional annotation | 可选的注解
-
getSignature
-
parameterCount
public int parameterCount()Get parameter count 获取参数数量- Returns:
- parameter count | 参数数量
-
hasNoParameters
public boolean hasNoParameters()Check if no parameters 检查是否无参数- Returns:
- true if no parameters | 无参数返回 true
-
isGetter
public boolean isGetter()Check if is getter method 检查是否为 getter 方法- Returns:
- true if getter | 是 getter 返回 true
-
isSetter
public boolean isSetter()Check if is setter method 检查是否为 setter 方法- Returns:
- true if setter | 是 setter 返回 true
-
isConstructor
public boolean isConstructor()Check if is constructor 检查是否为构造方法- Returns:
- true if constructor | 是构造方法返回 true
-
isStaticInitializer
public boolean isStaticInitializer()Check if is static initializer 检查是否为静态初始化块- Returns:
- true if static initializer | 是静态初始化块返回 true
-
equals
-
hashCode
-
toString
-