java8 lambda 표현식의 응용list와 맵의 변환 및 대상 집합 정렬

1910 단어
1.List map ( List ) ( key, value)
Map map = list.stream().collect(Collectors.toMap(s->s.get("route_code"), s -> s.get("COUNT")));
2. u1 u2 
List objs= logisticsRouteExtends.stream().sorted((u1, u2) -> u2.getNumbers().compareTo(u1.getNumbers())).collect(Collectors.toList());
3.
List groupCodes = list.stream().map(p -> p.getDispatchingGroupCode()).collect(Collectors.toList());

List goodsCodes = dispatchingPowers.stream().map(LogisticsDispatchingPower::getGoodsCode).collect(Collectors.toList());
4.
logisticsDispatchingUsers = logisticsDispatchingUsers.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(LogisticsDispatchingUser::getDispatchingGroupCode))), ArrayList::new));
5. List Map( null , )
Map map = list.stream().
        collect(Collectors.groupingBy(java.util.function.Function.identity(),Collectors.counting()));
6.
custLimitSets =  custLimitSets.stream().filter(custLimitSet -> ! strings.contains(custLimitSet.getCustNo())).collect(Collectors.toList());(strings null )

7. 문자열 집합에서null과 빈 필드 제거
List strings = new ArrayList<>();
strings.add(null);
strings.add("");list = list.stream().filter(s -> !strings.contains(s) ).collect(Collectors.toList());

8. 화해를 구한다
//기본 유형 int sum = userList.stream().mapToInt(User::getAge).sum();//BigDecimal 구화 BigDecimal invoice Amount = wholesale BillVos.stream().map(WholesaleBillVo::getSaleAmount).reduce(BigDecimal.ZERO, BigDecimal::add);

좋은 웹페이지 즐겨찾기