com.github.rxyor.common.util.lang2.BeanUtil Maven / Gradle / Ivy
package com.github.rxyor.common.util.lang2;
import com.alibaba.fastjson.JSON;
import java.util.List;
/**
*
*
*
*
* @author liuyang
* @date 2019/12/30 周一 11:25:00
* @since 1.0.0
*/
public class BeanUtil {
private BeanUtil() {
}
public static T clone(final T source, Class destClass) {
if (source == null) {
return null;
}
String json = JSON.toJSONString(source);
return JSON.parseObject(json, destClass);
}
public static List clone(List sourceList, Class destClass) {
if (sourceList == null) {
return null;
}
String json = JSON.toJSONString(sourceList);
return JSON.parseArray(json, destClass);
}
public static T copy(final Object source, Class destClass) {
if (source == null) {
return null;
}
String json = JSON.toJSONString(source);
return JSON.parseObject(json, destClass);
}
public static List copy(List> sourceList, Class destClass) {
if (sourceList == null) {
return null;
}
String json = JSON.toJSONString(sourceList);
return JSON.parseArray(json, destClass);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy