stream:app
集合分组:spa
Map<String, List<Student>> collect = list.stream().collect(Collectors.groupingBy(Student::getSex));ci
集合取出某一属性方法:get
List<String> tableNames=list.stream().map(User::getMessage).collect(Collectors.toList());
集合过滤filter:table
//过滤出符合条件的数据 List<Apple> filterList = appleList.stream().filter(a -> a.getName().equals("香蕉")).collect(Collectors.toList());
求和:email
BigDecimal totalMoney = appleList.stream().map(Apple::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
Map转List:stream
//邮箱集合 List<String> emails = bossCandyGrantBO.getMatchEmail().entrySet() .stream().map(entry->entry.getKey()).collect(Collectors.toList()); //设置匹配邮箱入参 MatchUserNoRequest matchEmailUserNoRequest = new MatchUserNoRequest(emails,MatchUserNoRequest.matchEmail); //批量查询匹配的邮箱 List<MatchUserNoBO> emailUserNos = memberQueryService.queryMatchEnableUserNo(matchEmailUserNoRequest); //循环遍历存入Map bossCandyGrantBO.getMatchEmail().forEach((k,v)->{ emailUserNos.stream() .filter(o->o.getEmail().equals(k)) .findFirst().ifPresent(o->userAmountBOList.add(new MatchUserAmountBO(o.getUserNo(),new BigDecimal(v)))); });