eclipse-collections
eclipse-collections copied to clipboard
Implement variants of groupBy that group at multiple levels.
Collectors.groupingBy() has an overload which accepts another Collector, allowing multi-level groupBys.
This guide includes this example:
Map<String, Map<BlogPostType, List>> map = posts.stream()
.collect(groupingBy(BlogPost::getAuthor, groupingBy(BlogPost::getType)));
RichIterable could have additional variants of groupBy that take 2 or 3 Functions and return a Map of Multimaps or a Map of Maps of Multimaps respectively.
Alternately, we could have a form of groupBy that takes a single key Function, and a second Function that transforms the resulting grouped RichIterables into anything, and returns a MapIterable.