toMap - bug

原因:AttachmentInfoRespnse::getAssociateKeyId 作为键重复了,代码没有指定如何处理

//Duplicate key:错误代码
final Map<LongString> keyIdWithPathMap = attachmentInfoResponse.stream().collect(Collections.toMap(AttachmentInfoRespnse::getAssociateKeyId, item -> Optional.of(item.getxxx()).orElse)))


//解决代码:toMap第三个参数可以指定当key 重复的时候值怎么取
final Map<LongString> keyIdWithPathMap = attachmentInfoResponse.stream().collect(Collections.toMap(AttachmentInfoRespnse::getAssociateKeyId, item -> Optional.of(item.getxxx()).orElse),(v1,v2) -> v1);

https://blog.csdn.net/weixin_44422604/article/details/119888769

posted @   chuangzhou  阅读(6)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
历史上的今天:
2023-01-19 Pytest - 测试用例管理及运行管理
2022-01-19 Python - 多线程
2022-01-19 Python 网络编程简单实现
点击右上角即可分享
微信分享提示