com.kasinf.framework.rest.web.util.ControllerUtils Maven / Gradle / Ivy
The newest version!
package com.kasinf.framework.rest.web.util;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import java.util.Map;
/**
* @author lkhsh
* 用于处理controller接收到的和返回的数据
*/
public class ControllerUtils {
public static void setPatchBean(Object t, Object old) {
Map objectMap = BeanUtil.beanToMap(t);
objectMap.forEach((k, v) -> {
if (v != null) {
ReflectUtil.invoke(old, StrUtil.upperFirstAndAddPre(k, "set"), v);
}
});
}
}