Constructor and Description |
---|
MethodInvoker(Method method)
构造
|
Modifier and Type | Method and Description |
---|---|
Method |
getMethod()
获取方法
|
String |
getName()
获取调用方法的名称。
|
Type[] |
getParamTypes()
获取方法参数类型
|
Type |
getType()
获取调用方法的返回类型或参数类型或字段类型。
|
Class<?> |
getTypeClass()
获取调用方法的返回类型或参数类型或字段类型。
|
<T> T |
invoke(Object target,
Object... args)
调用指定目标对象的方法。
|
<T> T |
invokeStatic(Object... args)
执行静态方法
|
static MethodInvoker |
of(Method method)
创建方法调用器
|
MethodInvoker |
setCheckArgs(boolean checkArgs)
设置是否检查参数
1. |
public MethodInvoker(Method method)
method
- 方法public static MethodInvoker of(Method method)
method
- 方法public Method getMethod()
public Type[] getParamTypes()
public Class<?> getTypeClass()
Invoker
getTypeClass
in interface Invoker
public MethodInvoker setCheckArgs(boolean checkArgs)
1. 参数个数是否与方法参数个数一致 2. 如果某个参数为null但是方法这个位置的参数为原始类型,则赋予原始类型默认值
checkArgs
- 是否检查参数public <T> T invoke(Object target, Object... args) throws HutoolException
Invoker
invoke
in interface Invoker
T
- 返回类型target
- 目标对象,调用的方法属于该对象。args
- 方法调用的参数数组。HutoolException
public <T> T invokeStatic(Object... args) throws HutoolException
T
- 对象类型args
- 参数对象HutoolException
- 多种异常包装Copyright © 2025. All rights reserved.