mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
lambda代替反射执行
This commit is contained in:
parent
01dc2450a0
commit
9784e8e2b4
@ -3,6 +3,7 @@ package cn.hutool.core.bean;
|
|||||||
import cn.hutool.core.annotation.AnnotationUtil;
|
import cn.hutool.core.annotation.AnnotationUtil;
|
||||||
import cn.hutool.core.annotation.PropIgnore;
|
import cn.hutool.core.annotation.PropIgnore;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.lang.func.LambdaUtil;
|
||||||
import cn.hutool.core.reflect.FieldUtil;
|
import cn.hutool.core.reflect.FieldUtil;
|
||||||
import cn.hutool.core.reflect.MethodUtil;
|
import cn.hutool.core.reflect.MethodUtil;
|
||||||
import cn.hutool.core.reflect.ModifierUtil;
|
import cn.hutool.core.reflect.ModifierUtil;
|
||||||
@ -153,7 +154,8 @@ public class PropDesc {
|
|||||||
*/
|
*/
|
||||||
public Object getValue(final Object bean) {
|
public Object getValue(final Object bean) {
|
||||||
if (null != this.getter) {
|
if (null != this.getter) {
|
||||||
return MethodUtil.invoke(bean, this.getter);
|
//return MethodUtil.invoke(bean, this.getter);
|
||||||
|
return LambdaUtil.buildGetter(this.getter).apply(bean);
|
||||||
} else if (ModifierUtil.isPublic(this.field)) {
|
} else if (ModifierUtil.isPublic(this.field)) {
|
||||||
return FieldUtil.getFieldValue(bean, this.field);
|
return FieldUtil.getFieldValue(bean, this.field);
|
||||||
}
|
}
|
||||||
@ -224,7 +226,8 @@ public class PropDesc {
|
|||||||
*/
|
*/
|
||||||
public PropDesc setValue(final Object bean, final Object value) {
|
public PropDesc setValue(final Object bean, final Object value) {
|
||||||
if (null != this.setter) {
|
if (null != this.setter) {
|
||||||
MethodUtil.invoke(bean, this.setter, value);
|
//MethodUtil.invoke(bean, this.setter, value);
|
||||||
|
LambdaUtil.buildSetter(this.setter).accept(bean, value);
|
||||||
} else if (ModifierUtil.isPublic(this.field)) {
|
} else if (ModifierUtil.isPublic(this.field)) {
|
||||||
FieldUtil.setFieldValue(bean, this.field, value);
|
FieldUtil.setFieldValue(bean, this.field, value);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user