Add Predicate.of(), Consumer.of(), etc.

Remi Forax forax at
Sat May 2 21:31:45 UTC 2015

Hi all,
today, I stubble on a variant of JDK-8050818 [1],
trying to call negate() on a lambda which is not yet a Predicate (due to 
target typing) which requires either to cast the lambda to a Predicate 
and everybody knows that cast are evil or to add a local variable.

I think there is a way to fix that, it's not very orthodox so I let you 
The idea is to introduce a static method 'of' on Predicate,
   class Predicate<T> {
     public static <T> Predicate<T> of(Predicate<T> predicate) {
       return predicate;

so one can write:
compared to

so the question is, does it it worth the cost to introduce a static 
method that basically do nothing on all functional interfaces of 



More information about the core-libs-dev mailing list