当前位置:网站首页>BeanUtils.copyProperties无法复制不同List集合问题解决 Lists.transform函数
BeanUtils.copyProperties无法复制不同List集合问题解决 Lists.transform函数
2022-07-28 05:17:00 【wang0112233】
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>26.0-jre</version>
</dependency>使用Lists.transform
list 为源数据(复制对象) price 为目标
//源数据
List<Pr> list = new ArrayList<>();
//使用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;
});
//使用function
List<DTO> price = Lists.transform(list, new Function<Pr, DTO>() {
@Nullable
@Override
public DTO apply(@Nullable Pr entity) {
// 内部对象的转换操作
DTO vo = new DTO();
vo.setCode(entity.getCode());
vo.setName(entity.getName());
vo.setId(entity.getId());
return vo;
}
});边栏推荐
- DELL远程控制卡 使用ipmitools设置ipmi
- PC端-bug记录
- Barbie q! How to analyze the new game app?
- Keil Chinese garbled code solution
- C language characters and strings
- JMeter related knowledge sorting
- Oracle用sql查询某张表的字段信息(字段类型、长度等)
- 【SLAM】LVI-SAM解析——综述
- Why is MD5 irreversible, but it may also be decrypted by MD5 free decryption website
- Specific differences between typedef and define
猜你喜欢

Keil Chinese garbled code solution

Microservice failure mode and building elastic system

The research group passed the thesis defense successfully

【ARXIV2203】SepViT: Separable Vision Transformer

7. < tag string and API trade-offs> supplement: Sword finger offer 05. replace spaces

自定义Json返回数据

【ARXIV2204】Vision Transformers for Single Image Dehazing

【ARXIV2203】CMX: Cross-Modal Fusion for RGB-X Semantic Segmentation with Transformers

How does Alibaba use DDD to split microservices?

The default isolation level of MySQL is RR. Why does Alibaba and other large manufacturers change to RC?
随机推荐
在ruoyi生成的对应数据库的代码 之后我该怎么做才能做出下边图片的样子
FreeRTOS个人笔记-任务通知
C language: some self realization of string functions
【ARXIV2205】Inception Transformer
[paper notes] - low illumination image enhancement - zeroshot - rrdnet Network - 2020-icme
How does Alibaba use DDD to split microservices?
New methods and features of ES6 built-in objects
You must configure either the server or JDBC driver (via the ‘serverTimezone)
Reading notes of SMT practical guide 1
mysql的日期与时间函数,varchar与date相互转换
【ARXIV2204】Vision Transformers for Single Image Dehazing
Read the paper -- a CNN RNN framework for clip yield prediction
[slam] lvi-sam analysis - Overview
Interpreting the source code of cfrunloopref
使用nfpm制作rpm包
Data imbalance: comprehensive sampling of anti fraud model (data imbalance)
21 day SQL punch in summary
【计算机三级信息安全】信息安全保障概述
The most detailed installation of windows10 virtual machine, install virtual machine by hand, and solve the problem that the Hyper-V option cannot be found in the home version window
Configuration experiment of building virtual private network based on MPLS