Extending Collector to handle a post-transform
Tim Peierls
tim at peierls.net
Wed May 29 06:57:17 PDT 2013
On Tue, May 28, 2013 at 5:59 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
> Overall I think this is a reasonable price to pay for making the
> abstraction more powerful.
>
For me, this tips over into unacceptable territory. It's a lot of API
complexity that most of the time wouldn't be used, so users would be
grappling with an extra type parameter unnecessarily. I think people are
going to be confused enough already by things like groupingBy; adding
post-transform would put even the simplest usage examples out of reach of
ordinary users.
If post-collect transformation is truly essential, I'd even go for having
two variants of each method that currently takes a Collector, one to take
non-post-transforming Collector<T, R> and one to take
CollectorAndTransformer<T, X, R>. I don't love adding methods, but at least
that way regular users could avoid the scary version.
--tim
More information about the lambda-libs-spec-observers
mailing list