| 构造器和说明 |
|---|
MethodInvoker(Method method)
构造
|
| 限定符和类型 | 方法和说明 |
|---|---|
Class<?> |
getType()
获取调用方法的返回类型或参数类型。
|
<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 MethodInvoker setCheckArgs(boolean checkArgs)
1. 参数个数是否与方法参数个数一致 2. 如果某个参数为null但是方法这个位置的参数为原始类型,则赋予原始类型默认值
checkArgs - 是否检查参数public <T> T invoke(Object target, Object... args) throws HutoolException
Invokerinvoke 在接口中 InvokerT - 返回类型target - 目标对象,调用的方法属于该对象。args - 方法调用的参数数组。HutoolExceptionpublic <T> T invokeStatic(Object... args) throws HutoolException
T - 对象类型args - 参数对象HutoolException - 多种异常包装Copyright © 2024. All rights reserved.