com.soento.core.util.BeanUtil Maven / Gradle / Ivy
package com.soento.core.util;
import org.apache.commons.beanutils.BeanUtils;
/**
* @author soento
*/
public class BeanUtil extends BeanUtils {
/**
* 对象构建
*
* @param from 拷贝源
* @param clazz 目标类
* @param 目标类泛型
* @return 结果对象
*/
public static T build(Object from, Class clazz) {
if (from == null) {
return null;
}
String json = JsonUtil.toJson(from);
return JsonUtil.toObject(json, clazz);
}
}