hg: lambda/lambda/jdk: Implement groupBy for both ordered and unordered sources

Arne Siegel v.a.ammodytes at googlemail.com
Tue Oct 23 13:48:17 PDT 2012

This excerpt from GroupByOp cries for a new overloaded requireNonNull in class Objects, as 
formatting an instance of an unknown type may be quite expensive:

        public void accept(T t) {
            K key = Objects.requireNonNull(mapper.map(t), String.format("The element %s cannot be mapped to a null key", t));

Two simple solutions come to mind: adding a Factory<String> parameter, or adding a 
Object... parameter and moving the format into requireNonNull.

Arne Siegel

On 22 Oct 2012 at 21:05, brian.goetz at oracle.com wrote:

> Changeset: 532efd9be743
> Author:    briangoetz
> Date:      2012-10-22 17:04 -0400
> URL:       http://hg.openjdk.java.net/lambda/lambda/jdk/rev/532efd9be743
> Implement groupBy for both ordered and unordered sources
> Contributed-By: paul.sandoz at oracle.com
> + src/share/classes/java/util/streams/ops/FlagDeclaringOp.java
> ! src/share/classes/java/util/streams/ops/GroupByOp.java
> ! test-ng/tests/org/openjdk/tests/java/util/streams/ops/GroupByOpTest.java
> ! test-ng/tests/org/openjdk/tests/java/util/streams/ops/StreamOpTestCase.java

More information about the lambda-dev mailing list