Collectors.collecting ?

Remi Forax forax at
Fri Jun 21 01:45:28 PDT 2013

Maybe the question is stupid, but I fail to understand why in collector API
we have a way to perform a reduction with no side effect but no way to 
do the same thing with side effect
(in fact there is a way with the newly introduced methods 'of' but it's 
verbose and not symmetric).

Currently we can write:
         Collectors.groupingByConcurrent(arg -> arg,
             Collectors.reducing(0, arg -> 1, Integer::sum)));

but neither
         Collectors.groupingByConcurrent(arg -> arg,
             Collectors.collecting(new MutableInt(), (arg, value) -> 
         Collectors.groupingByConcurrent(arg -> arg,
             Collectors.collectingConcurrent(new LongAdder(), (arg, 
adder) -> adder.increment())));


More information about the lambda-libs-spec-observers mailing list