1.map的key,value转list
List<Integer> list = new ArrayList<Integer>(map.keySet());
List<String> list = new ArrayList<String>(map.values());
2.取对象某属性为key
Map<String, List<User>> map =userList.stream().collect(Collectors.groupingBy(User::getName));
3.经过滤条件处理后
List<TyreProduct> withoutNullList = list.stream().filter(tyreProduct -> tyreProduct.getInch() != null || tyreProduct.getInch().trim().length() != 0).collect(Collectors.toList());
Map<String,List<TyreProduct>> map = withoutNullList.stream().collect(Collectors.groupingBy(TyreProduct::getInch));
4.map中套map
Map<Integer, Map<Integer, List<Person>>> groupsMap = personList.stream().collect( Collectors.groupingBy(Person::getSex, Collectors.groupingBy(Person::getAge)));
5.取对象list中某属性集合
List<Long> agentIds = hkAgentRelateItemList.stream().map(HkAgentRelateItem::getRelatedAgentId).collect(Collectors.toList());
6.排序
List<CarClubRebateRule> sortList = ruleList.stream().sorted((a, b) -> a.getLevel() - b.getLevel()).collect(Collectors.toList());