Dan Smith daniel.smith at
Thu Apr 18 12:10:14 PDT 2013

On Apr 18, 2013, at 12:56 PM, Mike Duigou <mike.duigou at> wrote:

> On Apr 18 2013, at 11:38 , Michael Nascimento wrote:
>> Hi folks,
>> Have you already considered a Predicates class / static methods in
>> Predicate with useful methods  such as alwaysTrue(), alwaysFalse(),
> We had this in the past but honestly t -> false is just simpler.
>> isNull() etc?
> We added Objects.isNull and Objects.isNonNull to be used as method references rather than on Predicates.

This is the general strategy to take for things like this, and a luxury Guava didn't have.  Example:

Predicate<String> isNull = Objects::isNull;

On performance: I'm sure Guava is optimized so that its methods always return a singleton.  In principle, the semantics of lambdas and method references are abstract enough that you shouldn't have to worry about that.  In practice, I wouldn't expect clever optimizations like that (e.g., turning every "x -> true" into the same object) in the near future.


More information about the lambda-dev mailing list