1.提取对象集合某一字段(list 转list)
List<String> codeList = MatePriceWhiteVoList.stream().map(MatePriceWhiteVo::getStoreCode).distinct().collect(Collectors.toList());
2.list 转换为 map
Map<String, String> codeMap = listShopList.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toMap(ShopReportVo::getCode, ShopReportVo::getName));
Map<String,ShopReportVo> map=listShopList.stream().collect(Collectors.toMap(ShopReportVo::getName,Function.identity()));
Map<String,ShopReportVo> map=listShopList.stream().collect(Collectors.toMap(ShopReportVo::getName,shopReportVo -> shopReportVo));
Map<String,List<ShopReportVo>> map=listShopList.stream().collect(Collectors.groupingBy(ShopReportVo::getName));
3.对list的操作(暂时只写了排序和过滤)
List<ShopReportVo> codeList =listShopByCodes.getResult().stream()
.filter(shopReportVo -> "A".equals(shopReportVo.getCode()))
.sorted(Comparator.comparing(ShopReportVo::getPlatformShopId).reversed()
.thenComparing(ShopReportVo::getName)
.thenComparing(ShopReportVo::getTagName))
.collect(Collectors.toList());
List<ShopReportVo> codeList =listShopByCodes.getResult().stream()
.filter(shopReportVo -> "A".equals(shopReportVo.getCode()))
.sorted(Comparator.comparing(ShopReportVo::getPlatformShopId,Comparator.reverseOrder())
.thenComparing(ShopReportVo::getName, Comparator.naturalOrder()))
.collect(Collectors.toList());