java 中bean 拷贝_java 对象属性复制(BeanCopy)最佳实践

常见的属性赋值工具

Frameworks that ease bean mapping.

dOOv - Provides fluent API for typesafe domain model validation and mapping. It uses annotations, code generation and a type safe DSL to make bean validation and mapping fast and easy.

Dozer - Mapper that copies data from one object to another using annotations and API or XML configuration.

JMapper - Uses byte code manipulation for lightning-fast mapping. Supports annotations and API or XML configuration.

MapStruct - Code generator that simplifies mappings between different bean types, based on a convention-over-configuration approach.

ModelMapper - Intelligent object mapping library that automatically maps objects to each other.

Orika - JavaBean-mapping framework that recursively copies (among other capabilities) data from one object to another.

Selma - Annotation processor-based bean mapper.

个人整理

我原来(2018年)对比过这些工具,Dozer 是相对比较成熟的工具。

对于性能而言,直接通过 CGLIB 生成的 BeanCopier 性能比较好。

如何自定义一个自己的属性赋值工具?

满足常见的 BeanUtils.copyProperties(); 的便利性

可以指定 null 值是否赋值等等。

自己设计一个属性赋值框架。

拓展阅读

参考资料

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值