Survey: API review for Collectors

Brian Goetz brian.goetz at oracle.com
Wed Apr 17 12:56:09 PDT 2013


Sam asks:

Why not specifically return an immutable set from toSet()?

I'd like this too.  This is due to the limitation of not being able to 
support a post-function in Collector.  (See my recent post on this on 
lambda-dev: 
http://mail.openjdk.java.net/pipermail/lambda-dev/2013-April/009394.html).

Related question: why does toStringJoiner not expose prefix/suffix?

This one is related -- we don't have any easy way to treat the root 
caculation differently from sub-results.  If we used () -> new 
StringJoiner(", ", "[", "]") as our result container, then if we did a 
parallel collect of intRange(1,6) where it happens to get split in half, 
the reslut would be:

  [1,2,3],[4,5,6]

instead of

  [1,2,3,4,5,6]

TO be able to do this right, we'd have to use a different construction 
of the stringjoiner for non-root results.  Extending Collector to handle 
all these cases (efficiently) was going to be pretty disruptive.  So we 
said goodbye to these pretty use cases.


On 4/17/2013 2:48 PM, Brian Goetz wrote:
> I've posted a survey for the static methods in Collectors at:
>    https://www.surveymonkey.com/s/LGV85RH
>
> I think the API here is mostly done; the spec and tutorial material
> still need work.
>
> Usual password.
>
>


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