T - the type of object “tested” by the predicate@FunctionalInterface public interface Predicate<T>
true or false for a value.
This type serves the same purpose as the JDK's Predicate, but allows throwing checked exceptions.
It contains methods for bridging to and from the JDK type.
| Modifier and Type | Field and Description |
|---|---|
static Predicate<Object> |
FALSE
A predicate that always returns
false, regardless of the input object. |
static Predicate<Object> |
TRUE
A predicate that always returns
true, regardless of the input object. |
| Modifier and Type | Method and Description |
|---|---|
static <T> Predicate<T> |
alwaysFalse()
A predicate that always returns
false, regardless of the input object. |
static <T> Predicate<T> |
alwaysTrue()
A predicate that always returns
true, regardless of the input object. |
boolean |
apply(T t)
Tests the given value.
|
static <T> Predicate<T> |
from(Predicate<T> predicate)
Creates a predicate from a JDK predicate.
|
static <T> Predicate<T> |
fromGuava(Predicate<T> predicate)
Creates a predicate from a Guava predicate.
|
default Predicate<T> |
toGuavaPredicate()
Creates a Guava
Predicate from this predicate. |
default Predicate<T> |
toPredicate()
Creates a JDK
Predicate from this predicate. |
static final Predicate<Object> TRUE
true, regardless of the input object.boolean apply(T t) throws Exception
t - the value to “test”true if the predicate applied, otherwise falseException - anydefault Predicate<T> toPredicate()
Predicate from this predicate.
Any exceptions thrown by this action will be unchecked via Exceptions.uncheck(Throwable) and rethrown.
default Predicate<T> toGuavaPredicate()
Predicate from this predicate.
Any exceptions thrown by this action will be unchecked via Exceptions.uncheck(Throwable) and rethrown.
static <T> Predicate<T> from(Predicate<T> predicate)
T - the type of object this predicate testspredicate - the JDK predicatestatic <T> Predicate<T> fromGuava(Predicate<T> predicate)
T - the type of object this predicate testspredicate - the Guava predicatestatic <T> Predicate<T> alwaysTrue()
true, regardless of the input object.T - the type of input objecttruestatic <T> Predicate<T> alwaysFalse()
false, regardless of the input object.T - the type of input objectfalse