|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Predicate<T>
Determines 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.
Implementations 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 if (myPredicate.apply(myObject)) ...
to throw a
NullPointerException
, it was decided not to make this change.
Method Summary | |
---|---|
boolean |
apply(T t)
Applies this predicate to the given object. |
boolean |
equals(Object obj)
Indicates whether some other object is equal to this Predicate . |
Method Detail |
---|
boolean apply(@Nullable T t)
t
boolean equals(Object obj)
Predicate
.
This method can return true
only if the specified object
is also a Predicate
and, for every input object o
, it
returns exactly the same value. Thus,
predicate1.equals(predicate2)
implies that either
predicate1.apply(o)
and predicate2.apply(o)
are both
true
, or both false
.
Note that it is always safe not to override
Object.equals(Object)
.
equals
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |