Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

集合Stream常用操作工具类 #115

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zee500231
Copy link

包含:转新集合,过滤,分组,排序,求和,平均,最大值,最小值,分隔,合并,去重
例子
//转新list 比如取出商品ids
List ids=CollStreamUtil.toList(commoditys,Commondity::getId);
//过滤出价格>100
List commoditys=CollStreamUtil.filterList(commoditys,commodity->commdity.getPrice().compareTo(BigDecimal.valueOf(100))>0);
//按商品类型分组
Map<String,List>=CollStreamUtil.groupBy(commoditys,Commondity::getCategory);
//按商品名称去重
List commoditys=CollStreamUtil.distinct(commoditys,Commondity::getName);
//合并两个商品集合
List commoditys=CollStreamUtil.mergeAll(commoditys1,commoditys2);
//合并两个商品集合通过name去重保留左边集合数据
List commoditys=CollStreamUtil.leftMerge(commoditys,Commondity::getName);
其它操作详见工具类。

@zee500231 zee500231 closed this Jul 31, 2023
@zee500231 zee500231 reopened this Jul 31, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant