Class MethodMetadata

java.lang.Object
cloud.opencode.base.classloader.metadata.MethodMetadata

public final class MethodMetadata extends Object
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 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

      public String methodName()
      Get method name 获取方法名
      Returns:
      method name | 方法名
    • returnType

      public String returnType()
      Get return type 获取返回类型
      Returns:
      return type | 返回类型
    • parameterTypes

      public List<String> parameterTypes()
      Get parameter types 获取参数类型
      Returns:
      list of parameter types | 参数类型列表
    • parameterNames

      public List<String> parameterNames()
      Get parameter names 获取参数名称
      Returns:
      list of parameter names | 参数名称列表
    • exceptionTypes

      public List<String> exceptionTypes()
      Get exception types 获取异常类型
      Returns:
      list of exception types | 异常类型列表
    • 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

      public List<AnnotationMetadata> annotations()
      Get annotations 获取注解
      Returns:
      list of annotations | 注解列表
    • parameterAnnotations

      public List<List<AnnotationMetadata>> parameterAnnotations()
      Get parameter annotations 获取参数注解
      Returns:
      list of parameter annotation lists | 参数注解列表的列表
    • getGenericSignature

      public String getGenericSignature()
      Get generic signature of the method 获取方法的泛型签名
      Returns:
      generic signature or null if not generic | 泛型签名,非泛型方法返回 null
    • getGenericReturnType

      public String getGenericReturnType()
      Get generic return type (e.g. "List<String>" instead of "List") 获取泛型返回类型(如 "List<String>" 而非 "List")
      Returns:
      generic return type or null | 泛型返回类型或 null
    • getGenericParameterTypes

      public List<String> getGenericParameterTypes()
      Get generic parameter types 获取泛型参数类型列表
      Returns:
      list of generic parameter type strings | 泛型参数类型字符串列表
    • 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

      public boolean hasAnnotation(String annotationClassName)
      Check if has specified annotation 检查是否有指定注解
      Parameters:
      annotationClassName - annotation class name | 注解类名
      Returns:
      true if has annotation | 有注解返回 true
    • getAnnotation

      public Optional<AnnotationMetadata> getAnnotation(String annotationClassName)
      Get specified annotation 获取指定注解
      Parameters:
      annotationClassName - annotation class name | 注解类名
      Returns:
      optional annotation | 可选的注解
    • getSignature

      public String getSignature()
      Get method signature 获取方法签名
      Returns:
      method signature | 方法签名
    • 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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object