How can I convert a Set<Result>
into a Map<Item, Set<String>>
or SetMultimap<Item, String>
using Java 8 streams or Multimaps, where Result
is:
class Result {
String name;
Set<Item> items;
}
For example, I start with:
result1:
name: name1
items:
- item1
- item2
result2:
name: name2
items:
- item2
- item3
and end with:
item1:
- name1
item2:
- name1
- name2
item3:
- name2
.collect(toList()).stream()
is unnecessary but you just edited it. thanks! – Father