提交 798549a3 编写于 作者: sq3536's avatar sq3536

版本升级

上级 a2550d5f
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<artifactId>ibizlab-common</artifactId> <artifactId>ibizlab-common</artifactId>
<name>ibizlab-common</name> <name>ibizlab-common</name>
<description>ibizlab-common</description> <description>ibizlab-common</description>
<version>1.0.3</version> <version>1.0.4</version>
<!-- Spring Boot --> <!-- Spring Boot -->
<parent> <parent>
......
package cn.ibizlab.util.helper; package cn.ibizlab.util.helper;
import org.springframework.cglib.beans.BeanCopier; import org.springframework.beans.BeanUtils;
import java.util.HashMap;
import java.util.Map;
public class CachedBeanCopier { public class CachedBeanCopier {
//创建过的BeanCopier实例放到缓存中,下次可以直接获取,提升性能
static final Map<String, BeanCopier> BEAN_COPIERS = new HashMap<String, BeanCopier>();
public static void copy(Object srcObj, Object destObj) { public static void copy(Object srcObj, Object destObj) {
copy(srcObj,destObj,false); copy(srcObj,destObj,false);
...@@ -16,18 +11,8 @@ public class CachedBeanCopier { ...@@ -16,18 +11,8 @@ public class CachedBeanCopier {
if(srcObj==null||destObj==null) { if(srcObj==null||destObj==null) {
return; return;
} }
getCopier(srcObj,destObj,useConverter).copy(srcObj, destObj, null); BeanUtils.copyProperties(srcObj, destObj);
} }
public synchronized static BeanCopier getCopier(Object srcObj, Object destObj,boolean useConverter) {
String key = srcObj.getClass().getName()+destObj.getClass().getName()+useConverter;
BeanCopier copier;
if (!BEAN_COPIERS.containsKey(key)) {
copier = BeanCopier.create(srcObj.getClass(), destObj.getClass(), useConverter);
BEAN_COPIERS.put(key, copier);
} else {
copier = BEAN_COPIERS.get(key);
}
return copier;
}
} }
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册