如何使用 Mapstruct 将嵌套 Map 转换为 POJO 列表
如何转换 Map
source:
Map<String, Map<String, Long>>
target:
List<DTO1>
DTO1:
private String name;
private List<DTO2> dto2List;
DTO2:
private String type;
private Long count;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可以使用一些自定义方法来进行此类映射。我假设映射条目集需要映射到列表。
例如
Doing such a mapping is possible with some custom methods. I assume that the map entry set needs to be mapped to the list.
e.g.
map.entrySet().stream().map(entry -> new DTO1(...)).collect(Collectors.toList())
map.entrySet().stream().map(entry -> new DTO1(...)).collect(Collectors.toList())