I have the following piece of code which groups the given entries (activities, which is Iterable<activity>
) based on IDs.
For the final result, I want it to return a Map
of ID to Iterables of the entries grouped by that ID.
For example: Map<String, Iterables<activity>>
.
Right now, it returns a Map<String, List<activity>>
.
stream(activities)
.collect(
groupingBy(
activity -> {
if (activity.getID()) {
return activity.getID();
} else {
return activity.getName();
}
}));
I am unable to figure out a way to do this.