lambda 将对象集合转换为map
List<Person> personList = new ArraysList<>();(只是示例)
Map<String, String> map = personList.stream().collect(Collectors.toMap(Person::getId, Person::getName));
lambda 将list转为新的list并将list转为逗号分隔的字符串
遍历list,从map中getKey(list(0),list(1)…)所存在元素的value,再将value组成的list转化为“,”(逗号分隔)的字符串。
List appIdList = new ArraysList<>();(只是示例)
StringUtils.join(appIdList.stream().map(Person::get).collect(Collectors.toList()), “,”);
lambda sorted按照对象某个属性排序
personList.stream().sorted(Comparator.comparing(Person::getDate).reversed()).collect(Collectors.toList());//按时间倒序
personList.stream().sorted(Comparator.comparing(Person::getDate)).collect(Collectors.toList());//按时间正序
lambda filter 按照某个条件过滤符合条件的对象
personList.stream().filter(e -> e.getStatus().equals(“valid”)).collect(Collectors.toList());