2 回答
TA贡献1848条经验 获得超2个赞
......
.stream()
.collect(Collectors.collectingAndThen(
Collectors.groupingBy(
x -> ImmutableList.of(x.getId()),
Collectors.mapping(
DomainObject::getDomainParam,
ImmutableList.toImmutableList())),
ImmutableMap::copyOf
));
TA贡献1789条经验 获得超8个赞
ImmutableMap<Long, ImmutableList<String>> groupedDomainObject(
List<DomainObject> domainObjectList) {
return domainObjectList
.stream()
.collect(
Collectors.collectingAndThen(
Collectors.toMap(
DomainObject::getId,
obj -> ImmutableList.of(obj.domainParam),
(a, b) -> ImmutableList.<String>builder().addAll(a).addAll(b).build()
),
ImmutableMap::copyOf
)
);
}
添加回答
举报