com.google.common.base
Interface Predicate<T>


public interface Predicate<T>

A Predicate can determine a true or false value for any input of its parameterized type. For example, a RegexPredicate might implement Predicate<String>, and return true for any String that matches its given regular expression.

Implementors of Predicate which may cause side effects upon evaluation are strongly encouraged to state this fact clearly in their API documentation.

NOTE: This interface could technically extend Function, since a predicate is just a special case of a function (one that returns a boolean). However, since implementing this would entail changing the signature of the apply(T) method to return a Boolean instead of a boolean, which would in turn allow people to return null from their Predicate, which would in turn enable code that looks like this if (myPredicate.apply(myObject)) ... to throw a NullPointerException, it was decided not to make this change.

Author:
Kevin Bourrillion

Method Summary
 boolean apply(T t)
          Applies this Predicate to the given object.
 

Method Detail

apply

boolean apply(@Nullable
              T t)
Applies this Predicate to the given object.

Returns:
the value of this Predicate when applied to input t