Java stream流 常用记录

根据列表中的某个字段进行去重

java 复制代码
// 根据roleKey对列表去重
            return roleList.stream()
                    .map(AccountRole::getRoleKey)
                    .distinct()
                    .map(roleKey -> roleList.stream()
                            .filter(role -> role.getRoleKey().equals(roleKey))
                            .findFirst()
                            .orElse(null))
                    .filter(Objects::nonNull)
                    .collect(Collectors.toList());
相关推荐
宸津-代码粉碎机13 小时前
微服务线上踩坑复盘:接口超时、负载倾斜隐形问题根治方案(生产级配置)
java·大数据·人工智能·python·spring
多多鼠13 小时前
System Prompt 的“版本漂移”问题:从变更管理到 A/B 测试体系
开发语言·网络·人工智能·python·langchain
LuTshoes13 小时前
spring ai 实战RAG(4)-模块化RAG
java·人工智能·spring
WiChP13 小时前
【V0.1B16】从零开始的2D游戏引擎开发之路
开发语言·算法·游戏引擎
事圆则缓13 小时前
Java I/O、文件与 Android 存储
java
wno70414 小时前
Spring Security基础使用
java·后端·spring
孙启超14 小时前
【AI开发之Rust】第 8 课:泛型、trait 与 trait 对象
开发语言·后端·rust
2501_9336707914 小时前
经营财务岗技能栈拆解:Excel、SQL、BI、预算分析怎么准备
开发语言
小蒜学长14 小时前
基于RFID技术的仓储管理系统设计(代码+数据库+LW)
java·数据库·spring boot·后端·rfid技术·仓储管理
梦影_14 小时前
Langchain简单快速上手教程(五)——聊天模型之流式传输
java·数据库·人工智能·python·langchain