当前位置:网站首页>BeanUtils.copyProperties() 对比 mapstruct
BeanUtils.copyProperties() 对比 mapstruct
2022-06-30 17:51:00 【帅大大的架构之路】
BeanUtils.copyProperties() 对比 mapstruct
文章目录
1.深拷贝与浅拷贝的区别
浅拷贝(shallowCopy)只是增加了一个指针指向已存在的内存地址,
深拷贝(deepCopy)是增加了一个指针并且申请了一个新的内存,使这个增加的指针指向这个新的内存,
深拷贝和浅拷贝最根本的区别在于是否真正获取一个对象的复制实体,而不是引用。
假设B复制了A,修改A的时候,看B是否发生变化:
如果B跟着也变了,说明是浅拷贝,拿人手短!(修改堆内存中的同一个值)
如果B没有改变,说明是深拷贝,自食其力!(修改堆内存中的不同的值)
2.BeanUtils是深拷贝还是浅拷贝
拷贝简单对象的时候是深拷贝
拷贝复杂对象的时候(对象属性里持有对象)是浅拷贝
3.mapstruct是深拷贝还是浅拷贝
拷贝简单对象的时候是深拷贝
拷贝复杂对象的时候(对象属性里持有对象)是浅拷贝
4.BeanUtils.copyProperties() VS mapstruct 性能对比
结论
BeanUtils.copyProperties() 和 mapstruct 都是浅拷贝,区别在于两者性能不同,mapstruct 性能更好一些
涉及到拷贝字段需要更改,或作一些特殊处理的时候mapstruct提供更好的解决方法
边栏推荐
- Solution of enterprise supply chain system in medical industry: realize collaborative visualization of medical digital intelligent supply chain
- slice
- 不同制造工艺对PCB上的焊盘的影响和要求
- 10 statistical methods commonly used for "dry goods" data analysis, with key application scenarios attached
- Memory Limit Exceeded
- 屏幕显示技术进化史
- How to seamlessly transition from traditional microservice framework to service grid ASM
- 3.10 haas506 2.0 development tutorial example TFT
- Video content production and consumption innovation
- Electronic components bidding and purchasing Mall: optimize traditional purchasing business and speed up enterprise digital upgrading
猜你喜欢
Ansi/ul 94 class 5-V vertical combustion test
屏幕显示技术进化史
Lenovo Yoga 27 2022, full upgrade of super configuration
Deep learning compiler understanding
Swin-Transformer(2021-08)
TCP粘包问题
Regular expressions (regular matching)
Pytorch learning (III)
Countdowncatch and completabilefuture and cyclicbarrier
拓维信息使用 Rainbond 的云原生落地实践
随机推荐
The easynvr platform equipment channels are all online. What is the reason for the "network request failure" in the operation?
【社区明星评选】第23期 7月更文计划 | 点滴创作,汇聚成塔!华为FreeBuds 4E等酷爽好礼送不停
Entry node of link in linked list - linked list topic
Small program container technology to promote the operation efficiency of the park
联想YOGA 27 2022,超强配置全面升级
ONEFLOW source code parsing: automatic inference of operator signature
链表中环的入口结点-链表专题
Cobbler轻松上手
PHP uses queues to solve maze problems
Rust 如何实现依赖注入?
torch.roll
Leader: who can use redis expired monitoring to close orders and get out of here!
torch stack() meshgrid()
手机股票账号开户安全吗?是靠谱的吗?
期货怎么开户安全些?现在哪些期货公司靠谱些?
How does rust implement dependency injection?
Swin-transformer --relative positional Bias
不同制造工艺对PCB上的焊盘的影响和要求
法国A+ 法国VOC标签最高环保级别
How to configure webrtc video stream format playback in the new version of easygbs?