java for loop with map merge [closed]

Simple conversion of one type to another.

Is there a better way with streams :

    Map<String, Set<String>> result = new HashMap<>();
for (Pair<String, String> pair : resultList) {
Set<String> strSet = new HashSet<>();
result.merge(pair.getLeft(), strSet, new BiFunction<Set<String>, Set<String>, Set<String>>() {
@Override
public Set<String> apply(Set<String> current, Set<String> additional) {
if (current == null) {
}
return current;
}
});
}
return result;


closed as too broad by yuri, Mathias Ettinger, Graipher, Toby Speight, esoteMay 14 at 12:00

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Questions about how to do things are better suited in stackoverflow.com . – TorbenPutkonen May 14 at 5:53

Sure. Use Collectors.groupingBy to build the Map<String, Set<String>> for you.
return resultList.stream()