当前位置:网站首页>BeanUtils. Copyproperties cannot copy different list sets problem solving lists.transform function
BeanUtils. Copyproperties cannot copy different list sets problem solving lists.transform function
2022-07-28 05:29:00 【wang0112233】
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>26.0-jre</version>
</dependency>Use Lists.transform
list For source data ( copy object ) price Target
// Source data
List<Pr> list = new ArrayList<>();
// Use lamda
List<DTO> price = Lists.transform(list, (entity) -> {
DTO vo = new DTO();
vo.setCode(entity.getCode());
vo.setName(entity.getCode());
vo.setId(entity.getId());
return vo;
});
// Use function
List<DTO> price = Lists.transform(list, new Function<Pr, DTO>() {
@Nullable
@Override
public DTO apply(@Nullable Pr entity) {
// Conversion of internal objects
DTO vo = new DTO();
vo.setCode(entity.getCode());
vo.setName(entity.getName());
vo.setId(entity.getId());
return vo;
}
});边栏推荐
- 7. < tag string and API trade-offs> supplement: Sword finger offer 05. replace spaces
- Mysql数据库索引(innodb引擎)
- Digital twin solutions inject new momentum into the construction of chemical parks
- regular expression
- 测试开发---自动化测试中的UI测试
- 【ARXIV2203】CMX: Cross-Modal Fusion for RGB-X Semantic Segmentation with Transformers
- Video twins: the starting point of informatization upgrading of smart Parks
- C language classic 100 question exercise (1~21)
- Reading notes of SMT practical guide 1
- SMD component size metric English system corresponding description
猜你喜欢

11.< tag-动态规划和子序列, 子数组>lt.115. 不同的子序列 + lt. 583. 两个字符串的删除操作 dbc

repackag failed: Unable to find main class

7.<tag-字符串和API的取舍>补充: 剑指 Offer 05. 替换空格

【ARXIV2204】Vision Transformers for Single Image Dehazing

MySQL basic query

Eccv2022 | 29 papers of Tencent Youtu were selected, including face security, image segmentation, target detection and other research directions

VMware Workstation 与 Device/Credential Guard 不兼容。禁用 Device/Credential Guard

Microservice failure mode and building elastic system

【CVPR2022】Lite Vision Transformer with Enhanced Self-Attention

测试开发---自动化测试中的UI测试
随机推荐
11. < tag dynamic programming and subsequence, subarray> lt.115. Different subsequences + Lt. 583. Deletion of two strings DBC
New methods and features of ES6 built-in objects
Autoreleasepool problem summary
FreeRTOS个人笔记-任务通知
Dell remote control card uses ipmitools to set IPMI
Eccv2022 | 29 papers of Tencent Youtu were selected, including face security, image segmentation, target detection and other research directions
repackag failed: Unable to find main class
PC side bug record
JVM note 4: Memory Model
restFul接口使用个人总结
PC端-bug记录
多线程进阶:synchronized底层原理,锁优化、锁升级的过程
How should programmers keep warm when winter is coming
regular expression
多系统架构设计思考
【SLAM】LVI-SAM解析——综述
C language: addition and deletion of linked list in structure
类和对象【中】
7. < tag string and API trade-offs> supplement: Sword finger offer 05. replace spaces
[slam] lvi-sam analysis - Overview