Updated State of the Collections
Sergey Kuksenko
sergey.kuksenko at oracle.com
Fri Nov 16 05:38:19 PST 2012
I have to note that suggested null handle example is not a filter. It is
an assert and the following explicit methods would be useful:
Stream<T> assert(Predicate<? super T> predicate);
and one of (or both):
Stream<T> assert(Predicate<? super T> predicate, Supplier<Throwable>
throwFactory);
or
Stream<T> assert(Predicate<? super T> predicate, Supplier<String>
messageFactory);
Open questions:
- name of methods (assert is keyword),
- to do connections with "-ea" option or not?
On 11/16/2012 02:26 PM, Arne Siegel wrote:
> Just one observation: the proposed way to handle the "error" strategy for nulls won't compile,
> as it fails to comply the contract for a Predicate:
>
> filter(e -> { (if e == null) throw new NPE(); }
>
>
> I can think of two compilable alternatives:
>
> filter(e -> { (if e == null) throw new NPE(); else return true; }
>
> tee(e -> { (if e == null) throw new NPE(); }
>
>
>
> On 15 Nov 2012 at 13:31, Brian Goetz wrote:
>
>> is here: http://cr.openjdk.java.net/~briangoetz/lambda/sotc3.html
>>
>
>
>
--
Best regards,
Sergey Kuksenko
More information about the lambda-dev
mailing list