Constructor and Description |
---|
FieldInvoker(Field field)
构造
|
Modifier and Type | Method and Description |
---|---|
Field |
getField()
获取字段
|
String |
getName()
获取调用方法的名称。
|
Type |
getType()
获取调用方法的返回类型或参数类型或字段类型。
|
Class<?> |
getTypeClass()
获取调用方法的返回类型或参数类型或字段类型。
|
<T> T |
invoke(Object target,
Object... args)
调用指定目标对象的方法。
|
Object |
invokeGet(Object obj)
获取字段值
|
void |
invokeSet(Object obj,
Object value)
设置字段值,传入的字段值必须和字段类型一致,否则抛出异常
|
static FieldInvoker |
of(Field field)
创建字段调用器
|
FieldInvoker |
setConverter(Converter converter)
设置字段值转换器
|
public FieldInvoker(Field field)
field
- 字段public static FieldInvoker of(Field field)
field
- 字段FieldInvoker
public Field getField()
public Class<?> getTypeClass()
Invoker
getTypeClass
in interface Invoker
public FieldInvoker setConverter(Converter converter)
converter
- 转换器,null
表示不转换public <T> T invoke(Object target, Object... args)
Invoker
public Object invokeGet(Object obj) throws HutoolException
obj
- 对象,static字段则此字段为nullHutoolException
- 包装IllegalAccessException异常public void invokeSet(Object obj, Object value) throws HutoolException
obj
- 对象,如果是static字段,此参数为nullvalue
- 值,值类型必须与字段类型匹配HutoolException
- UtilException 包装IllegalAccessException异常Copyright © 2025. All rights reserved.