从list中快速取出对象的某个属性值
List list = entityMapper.ToDTO(list);
List ids = list.stream().map(ClDTO::getClId).collect(Collectors.toList());
按照条件取出数据
List users = sysService.listUserByRole(nextRoleName);
users = users.stream().filter(e -> e.getPtion().equals("主管")).collect(Collectors.toList());
提取出list对象中的一个属性
List stIdList1 = stuList.stream().map(Person::getId).collect(Collectors.toList());
提取出list对象中的一个属性并去重
List stIdList2 = stuList.stream().map(Person::getId).distinct().collect(Collectors.toList());
按照某个字段去重得到list对象
ArrayList collect = result.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SysDepartment::getId))), ArrayList::new));
获取最小值
roleList.stream().mapToInt(SysRole -> SysRole.getDataPermission()).min().getAsInt();
标签:toList,stream,Collectors,List,list,collect
From: https://www.cnblogs.com/mjtabu/p/18244062