Class Parameter

java.lang.Object
cloud.opencode.base.reflect.invokable.Parameter
All Implemented Interfaces:
AnnotatedElement

public final class Parameter extends Object implements AnnotatedElement
Parameter Wrapper 参数包装

Wraps a method/constructor parameter with additional metadata.

包装方法/构造器参数及其附加元数据。

Features | 主要功能:

  • Type information access - 类型信息访问
  • Parameter name access - 参数名访问
  • Annotation access - 注解访问
  • Parameter metadata - 参数元数据

Usage Examples | 使用示例:

Parameter param = invokable.getParameters().get(0);
String name = param.getName();
TypeToken<?> type = param.getType();
boolean hasAnnotation = param.isAnnotationPresent(NotNull.class);

Security | 安全性:

  • Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
  • Null-safe: No (parameter must be non-null) - 空值安全: 否(参数须非空)
Since:
JDK 25, opencode-base-reflect V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • Parameter

      public Parameter(Parameter parameter, int index)
      Creates a Parameter wrapper 创建参数包装
      Parameters:
      parameter - the underlying parameter | 底层参数
      index - the parameter index | 参数索引
  • Method Details

    • getType

      public TypeToken<?> getType()
      Gets the parameter type as TypeToken 获取参数类型的TypeToken
      Returns:
      TypeToken of parameter type | 参数类型的TypeToken
    • getRawType

      public Class<?> getRawType()
      Gets the raw parameter type 获取原始参数类型
      Returns:
      the raw type | 原始类型
    • getName

      public String getName()
      Gets the parameter name 获取参数名
      Returns:
      the parameter name | 参数名
    • isNamePresent

      public boolean isNamePresent()
      Checks if the parameter name is present 检查参数名是否存在
      Returns:
      true if name is present | 如果名称存在返回true
    • getIndex

      public int getIndex()
      Gets the parameter index 获取参数索引
      Returns:
      the index | 索引
    • isVarArgs

      public boolean isVarArgs()
      Checks if this is a varargs parameter 检查是否为可变参数
      Returns:
      true if varargs | 如果是可变参数返回true
    • isImplicit

      public boolean isImplicit()
      Checks if this is an implicit parameter 检查是否为隐式参数
      Returns:
      true if implicit | 如果是隐式参数返回true
    • isSynthetic

      public boolean isSynthetic()
      Checks if this is a synthetic parameter 检查是否为合成参数
      Returns:
      true if synthetic | 如果是合成参数返回true
    • getUnderlying

      public Parameter getUnderlying()
      Gets the underlying parameter 获取底层参数
      Returns:
      the underlying parameter | 底层参数
    • isAnnotationPresent

      public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
      Specified by:
      isAnnotationPresent in interface AnnotatedElement
    • getAnnotation

      public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
      Specified by:
      getAnnotation in interface AnnotatedElement
    • getAnnotations

      public Annotation[] getAnnotations()
      Specified by:
      getAnnotations in interface AnnotatedElement
    • getAnnotationsByType

      public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationClass)
      Specified by:
      getAnnotationsByType in interface AnnotatedElement
    • getDeclaredAnnotation

      public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationClass)
      Specified by:
      getDeclaredAnnotation in interface AnnotatedElement
    • getDeclaredAnnotationsByType

      public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationClass)
      Specified by:
      getDeclaredAnnotationsByType in interface AnnotatedElement
    • getDeclaredAnnotations

      public Annotation[] getDeclaredAnnotations()
      Specified by:
      getDeclaredAnnotations in interface AnnotatedElement
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object