RFR 8071600: Add a flat-mapping collector

Chris Hegarty chris.hegarty at oracle.com
Thu Feb 12 14:33:17 UTC 2015


On 3 Feb 2015, at 13:48, Paul Sandoz <paul.sandoz at oracle.com> wrote:

> Hi,
> 
> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8071600-Collector-flatMapping/webrev/

Looks like a useful addition.

Trivially, the handling of null caught my eye: "If a mapped stream is {@code null} an empty stream is used, instead.”  It looks like the result of the mapper function returning null is equivalent to it returning an empty stream, but I’m not sure that I see an empty stream being used in the implementation. Is this just a convenience, for implementers of the mapping function? 

-Chris.

> This patch adds a new flat mapping collector to Collectors. This can be useful if one needs to map 0 or more items into a downstream collector.
> 
> A CCC will be filed.
> 
> A following patch, which i plan to fold into the above patch, performs some renames on the collectors test to be consistent with the current naming: 
> 
> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8071600-Collector-flatMapping-test-rename/webrev/
> 
> Thanks,
> Paul.




More information about the core-libs-dev mailing list