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 | Method and Description |
---|---|
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. |
boolean apply(T t) throws Exception
t
- the value to “test”true
if the predicate applied, otherwise false
Exception
- 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 predicate