Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
勤为径苦作舟
ZUtil
提交
17b735d4
Z
ZUtil
项目概览
勤为径苦作舟
/
ZUtil
大约 1 年 前同步成功
通知
6
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
ZUtil
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
17b735d4
编写于
5月 04, 2023
作者:
勤为径苦作舟
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: BeanUtils 新增 deepClone(深克隆)方法和深克隆性能测试
上级
4920e333
变更
3
展开全部
显示空白变更内容
内联
并排
Showing
3 changed file
with
479 addition
and
2 deletion
+479
-2
pom.xml
pom.xml
+66
-2
src/main/java/top/csaf/bean/BeanUtils.java
src/main/java/top/csaf/bean/BeanUtils.java
+27
-0
src/test/java/top/csaf/jmh/base/beans/DeepCloneTest.java
src/test/java/top/csaf/jmh/base/beans/DeepCloneTest.java
+386
-0
未找到文件。
pom.xml
浏览文件 @
17b735d4
...
@@ -130,7 +130,18 @@
...
@@ -130,7 +130,18 @@
<dependency>
<dependency>
<groupId>
org.yaml
</groupId>
<groupId>
org.yaml
</groupId>
<artifactId>
snakeyaml
</artifactId>
<artifactId>
snakeyaml
</artifactId>
<version>
1.33
</version>
<version>
2.0
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-core
</artifactId>
<version>
1.4.6
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-classic
</artifactId>
<version>
1.4.6
</version>
</dependency>
</dependency>
...
@@ -172,7 +183,7 @@
...
@@ -172,7 +183,7 @@
<dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<artifactId>
hutool-all
</artifactId>
<version>
5.8.1
</version>
<version>
5.8.1
1
</version>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<dependency>
...
@@ -193,6 +204,54 @@
...
@@ -193,6 +204,54 @@
<!-- <version>31.1-jre</version>-->
<!-- <version>31.1-jre</version>-->
<!-- <scope>test</scope>-->
<!-- <scope>test</scope>-->
<!--</dependency>-->
<!--</dependency>-->
<dependency>
<groupId>
com.esotericsoftware
</groupId>
<artifactId>
kryo
</artifactId>
<version>
5.5.0
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.wicketstuff
</groupId>
<artifactId>
wicketstuff-serializer-fast2
</artifactId>
<version>
9.13.0
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.caucho
</groupId>
<artifactId>
hessian
</artifactId>
<version>
4.0.66
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
io.protostuff
</groupId>
<artifactId>
protostuff-core
</artifactId>
<version>
1.8.0
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
io.protostuff
</groupId>
<artifactId>
protostuff-runtime
</artifactId>
<version>
1.8.0
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.dyuproject.protostuff
</groupId>
<artifactId>
protostuff-core
</artifactId>
<version>
1.3.0
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.dyuproject.protostuff
</groupId>
<artifactId>
protostuff-runtime
</artifactId>
<version>
1.3.0
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.objenesis
</groupId>
<artifactId>
objenesis
</artifactId>
<version>
3.3
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
@@ -385,6 +444,11 @@
...
@@ -385,6 +444,11 @@
<name>
Maven Central
</name>
<name>
Maven Central
</name>
<url>
https://repo.maven.apache.org/maven2/
</url>
<url>
https://repo.maven.apache.org/maven2/
</url>
</repository>
</repository>
<!-- jitpack -->
<repository>
<id>
jitpack.io
</id>
<url>
https://jitpack.io
</url>
</repository>
</repositories>
</repositories>
<pluginRepositories>
<pluginRepositories>
<pluginRepository>
<pluginRepository>
...
...
src/main/java/top/csaf/bean/BeanUtils.java
浏览文件 @
17b735d4
package
top.csaf.bean
;
package
top.csaf.bean
;
import
com.alibaba.fastjson2.JSON
;
import
lombok.NonNull
;
import
lombok.NonNull
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.beanutils.PropertyUtils
;
import
org.apache.commons.beanutils.PropertyUtils
;
...
@@ -356,4 +357,30 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
...
@@ -356,4 +357,30 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
}
}
return
targetList
;
return
targetList
;
}
}
/**
* 深克隆
*
* @param source 源对象
* @param <T> 源对象类型
* @return 深克隆后的对象
*/
public
static
<
T
>
T
deepClone
(
T
source
)
{
return
(
T
)
JSON
.
parseObject
(
JSON
.
toJSONString
(
source
),
source
.
getClass
());
}
/**
* 深克隆
*
* @param source 源集合
* @param <T> 源集合元素类型
* @return 深克隆后的集合
*/
public
static
<
T
>
List
<
T
>
deepClone
(
List
<
T
>
source
)
{
List
<
T
>
result
=
new
ArrayList
<>();
for
(
T
t
:
source
)
{
result
.
add
(
deepClone
(
t
));
}
return
result
;
}
}
}
src/test/java/top/csaf/jmh/base/beans/DeepCloneTest.java
0 → 100644
浏览文件 @
17b735d4
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录