1. 跟據某個屬性分組OfficeId:對象
Map<String, List<IncomeSumPojo>> collect = list.stream().collect(Collectors.groupingBy(IncomeSumPojo::getOfficeId));get
2. 根據某個屬性分組OfficeId,彙總某個屬性Money:io
Map<String, Double> collect = list.stream().collect(Collectors.groupingBy(IncomeSumPojo::getOfficeId,Collectors.summingDouble(IncomeSumPojo::getMoney)));
table
3. 根據某個屬性添加條件過濾數據:stream
list = list.stream().filter(u -> !u.getAmount().equals("0.00")).collect(Collectors.toList());List
4. 判斷一組對象裏面有沒有屬性值是某個值:map
List<Menu> menuList = UserUtils.getMenuList();
boolean add = menuList.stream().anyMatch(m -> "plan:ctPlan:add".equals(m.getPermission()));
數據
5. 取出一組對象的某個屬性組成一個新集合:filter
List<String> tableNames=list.stream().map(User::getMessage).collect(Collectors.toList());tab
6. list去重複:
list = list.stream().distinct().collect(Collectors.toList());