|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.common.base.Predicates
public final class Predicates
Contains static methods for creating the standard set of Predicate
objects.
"Lispy, but good."
TODO: considering having these implement a VisitablePredicate
interface which specifies an accept(PredicateVisitor)
method.
Method Summary | ||
---|---|---|
static
|
alwaysFalse()
Returns a predicate that always evaluates to false . |
|
static
|
alwaysTrue()
Returns a predicate that always evaluates to true . |
|
static
|
and(Iterable<? extends Predicate<? super T>> components)
Returns a predicate that evaluates to true iff each of its
components evaluates to true . |
|
static
|
and(Predicate<? super T>... components)
Returns a predicate that evaluates to true iff each of its
components evaluates to true . |
|
static
|
and(Predicate<? super T> first,
Predicate<? super T> second)
Returns a predicate that evaluates to true iff both of its
components evaluate to true . |
|
static
|
compose(Predicate<? super B> predicate,
Function<? super A,? extends B> function)
Returns the composition of a function and a predicate. |
|
static
|
in(Collection<?> target)
Returns a predicate that evaluates to true if the object reference
being tested is a member of the given collection. |
|
static
|
isEqualTo(T target)
Returns a predicate that evaluates to true iff the object being
tested equals() the given target or if both are null. |
|
static
|
isNull()
Returns a predicate that evaluates to true if the object reference being tested is null. |
|
static Predicate<Object> |
isSameAs(Object target)
Returns a predicate that evaluates to true iff the object being
tested refers to the same object as the given target. |
|
static
|
not(Predicate<? super T> predicate)
Returns a predicate that evaluates to true iff the given predicate evaluates to false . |
|
static
|
notNull()
Returns a predicate that evaluates to true if the object reference being tested is not null. |
|
static
|
or(Iterable<? extends Predicate<? super T>> components)
Returns a predicate that evaluates to true iff any one of its
components evaluates to true . |
|
static
|
or(Predicate<? super T>... components)
Returns a predicate that evaluates to true iff any one of its components evaluates to true. |
|
static
|
or(Predicate<? super T> first,
Predicate<? super T> second)
Returns a predicate that evaluates to true iff either of its
components evaluates to true . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T> Predicate<T> alwaysTrue()
true
.
public static <T> Predicate<T> alwaysFalse()
false
.
public static <T> Predicate<T> isNull()
public static <T> Predicate<T> notNull()
public static <T> Predicate<T> not(Predicate<? super T> predicate)
false
.
public static <T> Predicate<T> and(Iterable<? extends Predicate<? super T>> components)
true
iff each of its
components evaluates to true
. The components are evaluated in
order, and evaluation will be "short-circuited" as soon as the answer is
determined. Does not defensively copy the iterable passed in, so future
changes to it will alter the behavior of this predicate. If
components
is empty, the returned predicate will always evaluate to
true
.
public static <T> Predicate<T> and(Predicate<? super T>... components)
true
iff each of its
components evaluates to true
. The components are evaluated in
order, and evaluation will be "short-circuited" as soon as the answer is
determined. Does not defensively copy the array passed in, so future
changes to it will alter the behavior of this predicate. If
components
is empty, the returned predicate will always evaluate to
true
.
public static <T> Predicate<T> and(Predicate<? super T> first, Predicate<? super T> second)
true
iff both of its
components evaluate to true
. The components are evaluated in
order, and evaluation will be "short-circuited" as soon as the answer is
determined.
public static <T> Predicate<T> or(Iterable<? extends Predicate<? super T>> components)
true
iff any one of its
components evaluates to true
. The components are evaluated in
order, and evaluation will be "short-circuited" as soon as the answer is
determined. Does not defensively copy the iterable passed in, so future
changes to it will alter the behavior of this predicate. If
components
is empty, the returned predicate will always evaluate to
false
.
public static <T> Predicate<T> or(Predicate<? super T>... components)
public static <T> Predicate<T> or(Predicate<? super T> first, Predicate<? super T> second)
true
iff either of its
components evaluates to true
. The components are evaluated in
order, and evaluation will be "short-circuited" as soon as the answer is
determined.
public static <T> Predicate<T> isEqualTo(@Nullable T target)
true
iff the object being
tested equals()
the given target or if both are null.
TODO: Change signature to return Predicate<Object>
public static Predicate<Object> isSameAs(@Nullable Object target)
true
iff the object being
tested refers to the same object as the given target.
public static <T> Predicate<T> in(Collection<?> target)
true
if the object reference
being tested is a member of the given collection. Does not defensively copy
the collection passed in, so future changes to it will alter the behavior
of the predicate.
target
- the collection to test againstpublic static <A,B> Predicate<A> compose(Predicate<? super B> predicate, Function<? super A,? extends B> function)
x
,
the generated predicate returns predicate(function(x))
.
Functions.compose(Function, Function)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |