eclipse-collections icon indicating copy to clipboard operation
eclipse-collections copied to clipboard

Implement variants of groupBy that group at multiple levels.

Open motlin opened this issue 7 years ago • 0 comments

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.

motlin avatar Feb 20 '18 19:02 motlin