Class ConstructorInvokable<T>

java.lang.Object
cloud.opencode.base.reflect.invokable.Invokable<T,T>
cloud.opencode.base.reflect.invokable.ConstructorInvokable<T>
Type Parameters:
T - the type | 类型
All Implemented Interfaces:
AnnotatedElement

public final class ConstructorInvokable<T> extends Invokable<T,T>
Constructor Invokable Implementation 构造器Invokable实现

Implementation of Invokable for Constructor objects.

Constructor对象的Invokable实现。

Features | 主要功能:

  • Constructor wrapping as Invokable - 将构造器包装为Invokable
  • Type-safe constructor invocation - 类型安全的构造器调用
  • Parameter and annotation access - 参数和注解访问

Usage Examples | 使用示例:

Invokable<User, User> invokable = Invokable.from(constructor);
User user = invokable.invoke(null, "Alice", 25);

Security | 安全性:

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

    • getConstructor

      public Constructor<T> getConstructor()
      Gets the underlying Constructor 获取底层Constructor
      Returns:
      the Constructor | 构造器
    • getAccessibleObject

      protected AccessibleObject getAccessibleObject()
      Description copied from class: Invokable
      Gets the underlying accessible object 获取底层可访问对象
      Specified by:
      getAccessibleObject in class Invokable<T,T>
      Returns:
      the accessible object | 可访问对象
    • getDeclaringClass

      public TypeToken<T> getDeclaringClass()
      Description copied from class: Invokable
      Gets the declaring class as TypeToken 获取声明类的TypeToken
      Specified by:
      getDeclaringClass in class Invokable<T,T>
      Returns:
      TypeToken of declaring class | 声明类的TypeToken
    • getDeclaringClassRaw

      public Class<?> getDeclaringClassRaw()
      Description copied from class: Invokable
      Gets the declaring class as raw Class 获取声明类的原始Class
      Specified by:
      getDeclaringClassRaw in class Invokable<T,T>
      Returns:
      the declaring class | 声明类
    • getReturnType

      public TypeToken<T> getReturnType()
      Description copied from class: Invokable
      Gets the return type as TypeToken 获取返回类型的TypeToken
      Specified by:
      getReturnType in class Invokable<T,T>
      Returns:
      TypeToken of return type | 返回类型的TypeToken
    • getParameters

      public List<Parameter> getParameters()
      Description copied from class: Invokable
      Gets the parameter list 获取参数列表
      Specified by:
      getParameters in class Invokable<T,T>
      Returns:
      list of Parameters | 参数列表
    • getParameterTypes

      public List<TypeToken<?>> getParameterTypes()
      Description copied from class: Invokable
      Gets the parameter types 获取参数类型
      Specified by:
      getParameterTypes in class Invokable<T,T>
      Returns:
      list of parameter TypeTokens | 参数TypeToken列表
    • getExceptionTypes

      public List<TypeToken<? extends Throwable>> getExceptionTypes()
      Description copied from class: Invokable
      Gets the exception types 获取异常类型
      Specified by:
      getExceptionTypes in class Invokable<T,T>
      Returns:
      list of exception TypeTokens | 异常TypeToken列表
    • getTypeParameters

      public TypeVariable<?>[] getTypeParameters()
      Description copied from class: Invokable
      Gets the type parameters 获取类型参数
      Specified by:
      getTypeParameters in class Invokable<T,T>
      Returns:
      array of type variables | 类型变量数组
    • invoke

      public T invoke(T receiver, Object... args) throws InvocationTargetException, IllegalAccessException
      Description copied from class: Invokable
      Invokes the method/constructor 调用方法/构造器
      Specified by:
      invoke in class Invokable<T,T>
      Parameters:
      receiver - the receiver object | 接收对象
      args - the arguments | 参数
      Returns:
      the result | 结果
      Throws:
      InvocationTargetException - if invocation fails | 如果调用失败
      IllegalAccessException - if access denied | 如果访问被拒绝
    • isVarArgs

      public boolean isVarArgs()
      Description copied from class: Invokable
      Checks if varargs 检查是否为可变参数
      Specified by:
      isVarArgs in class Invokable<T,T>
      Returns:
      true if varargs | 如果是可变参数返回true
    • isSynthetic

      public boolean isSynthetic()
      Description copied from class: Invokable
      Checks if synthetic 检查是否为合成
      Specified by:
      isSynthetic in class Invokable<T,T>
      Returns:
      true if synthetic | 如果是合成返回true
    • getName

      public String getName()
      Description copied from class: Invokable
      Gets the name 获取名称
      Specified by:
      getName in class Invokable<T,T>
      Returns:
      the name | 名称
    • getModifiers

      public int getModifiers()
      Description copied from class: Invokable
      Gets the modifiers 获取修饰符
      Specified by:
      getModifiers in class Invokable<T,T>
      Returns:
      the modifiers | 修饰符
    • 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