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

Paul Benedict pbenedict at apache.org
Tue Oct 23 13:53:55 PDT 2012


Note that String.format is being executed always (a waste of time) even if
no NPE is going to happen. I say replace it with a simple if-check to defer
formatting until you need it.

On Tue, Oct 23, 2012 at 3:48 PM, Arne Siegel
<v.a.ammodytes at googlemail.com>wrote:

> 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