条件筛选
AssignCourseType assignCourseType = assignCourseTypeList.stream().filter(f -> f.getOurseName().contains("一次")).findFirst().orElse(null);
分组
Map<Long, List<SalaryStandardVo>> standardUserGroup = salaryStandardList.stream().collect(Collectors.groupingBy(SalaryStandardVo::getUpmsUserId));
去重
List<SalaryStandardVo> distinctSalaryStandardList = salaryStandardList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SalaryStandardVo::getIncentiveCode))), ArrayList::new));
获取list对象中的某个字段
List<Long> empIds = deptMangerRes.stream().map(DeptMangerRes::getEmployeeId).collect(Collectors.toList());
求和
int mathSumInt = list.stream().mapToInt( Student::getMathScoresInt ).sum(); //int类型
long mathSumLong = list.stream().mapToLong( Student::getMathScoresLong ).sum(); //long类型
double mathSumDouble = list.stream().mapToDouble( Student::getMathScoresDouble ).sum(); //double类型
BigDecimal mathSumBigDecimal = list.stream().map( Student::getMathScoresBigDecimal ).reduce(BigDecimal.ZERO, BigDecimal::add); //BigDecimal类型
转Map
Map<String,Integer> sourceMap = source.stream().collect(Collectors.toMap(AppTodoType::getSourceName,AppTodoType::getSource));