Stream流根据某一属性分组
用法
list.stream().collect(Collectors.groupingBy(entity -> entity.getParam()))
eg :
{type = "类型一",name = 1}
{type = "类型一",name = 2}
{type = "类型二",name = 3}
{type = "类型二",name = 4}
{type = "类型三",name = 5}
{type = "类型三",name = 6}
得到的结果 :Map {
"类型一":
[{type = "类型一",name = 1},{type = "类型一",name = 2}] ,
"类型二":
[{type = "类型二",name = 3},{type = "类型二",name = 4}] ,
"类型三":
[{type = "类型三",name = 5},{type = "类型三",name = 6}]
}