jdk1.8 list特性
LIST分组
Map<String,CommodityVO> map = new HashMap<>(); List<CommodityVO> list = dao.list(applyId); if (CollectionUtil.isNotEmpty(list)) { map = list.stream().collect(Collectors.toMap(x -> x.getCommodityId() ,Function.identity())); }
多字段去重
List<CatTest> catList = Lists.newArrayList(); catList.stream() .collect( Collectors.collectingAndThen( Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(cat -> cat.getCarHobby() + cat.getCatName()))), ArrayList::new ) );