hg: lambda/lambda/jdk: Cleanup in Optional
Gernot Neppert
mcnepp02 at googlemail.com
Fri Nov 23 00:36:53 PST 2012
Hi Brian,
I do think that having factory methods 'empy()' and 'of(T)' and no public
constructor is a good thing, I wonder whether it's necessary to make
'of(T)' is so restrictive: it throws NullPointerException if the supplied
value is null.
So why place the burdon of picking the correct factory method upon the user?
Why not simply have:
public static <T> Optional<T> of(T value) {
return value == null ? empty() : new Optional<T>(value);
}
2012/11/15 <brian.goetz at oracle.com>
> Changeset: ab258565c0c9
> Author: briangoetz
> Date: 2012-11-15 17:19 -0500
> URL: http://hg.openjdk.java.net/lambda/lambda/jdk/rev/ab258565c0c9
>
> Cleanup in Optional
>
> ! src/share/classes/java/util/Optional.java
> ! src/share/classes/java/util/streams/ops/FindAnyOp.java
> ! src/share/classes/java/util/streams/ops/FindFirstOp.java
> ! src/share/classes/java/util/streams/ops/SeedlessFoldOp.java
>
>
>
More information about the lambda-dev
mailing list