Java 8流式操作

  1. 集合根据id分组
Map<String, List<AreaBO>> areaGroupByLevel = areaList.stream()
				.collect(Collectors.groupingBy(AreaBO::getParent));

2.过滤

List<SkuSupermarketBO> priceList = value.stream().filter(item -> item != null && item.getPrice() != null)
					.collect(Collectors.toList());

3.提取id重组集合

List<Long> skuIdList = SkuCommunityList.stream()
.collect(Collectors.mapping(SkuCommunityBO::getGoodsSkuId, Collectors.toList()));

猜你喜欢

转载自blog.csdn.net/qq_40354317/article/details/84988878