@NonnullByDefault public final class Predicates extends Object
Predicates.| Modifier and Type | Method and Description |
|---|---|
static <T> Predicate<T> |
alwaysFalse()
Returns a predicate which always returns false
|
static <T> Predicate<T> |
alwaysTrue()
Returns a predicate which always returns true
|
static <A,B> Predicate<A> |
compose(Function<A,? extends B> function,
Predicate<B> predicate)
Returns a predicate which takes the input, passes it through the given
function, and then obtains a result from the delegate predicate.
|
static <A,B> Predicate<A> |
equalTo(Function<A,? extends B> composeFunction,
Object target)
Returns a predicate which takes the input, passes it through the given
function, and then evaluates the result against
equalTo(Object). |
static <T> Predicate<T> |
equalTo(Object target)
Returns a predicate which returns true if the target is
Object.equals(Object) to the input. |
static <T> Predicate<T> |
in(Collection<? extends T> collection)
Returns a predicate which returns true if the input is contained within
the given collection.
|
static <A,B> Predicate<A> |
in(Function<A,? extends B> composeFunction,
B... args)
Returns a predicate which takes the input, passes it through the given
function, and then evaluates the result against
in(Object[]). |
static <A,B> Predicate<A> |
in(Function<A,? extends B> composeFunction,
Collection<? extends B> collection)
Returns a predicate which takes the input, passes it through the given
function, and then evaluates the result against
in(Collection). |
static <T> Predicate<T> |
in(T... args)
Returns a predicate which returns true if the input is contained within
the given var args.
|
static <T> Predicate<T> |
instanceOf(Class<?> clazz)
Returns a predicate which returns true if the input is an instance of the
given class.
|
static <A,B> Predicate<A> |
instanceOf(Function<A,? extends B> composeFunction,
Class<?> clazz)
Returns a predicate which takes the input, passes it through the given
function, and then evaluates the result against
instanceOf(Class). |
static <T> Predicate<T> |
isNull()
Returns a predicate which returns true if the input is null,
false otherwise.
|
static <A,B> Predicate<A> |
isNull(Function<A,? extends B> composeFunction)
Returns a predicate which takes the input, passes it through the given
function, and then evaluates the result against
isNull(). |
static <T> Predicate<T> |
notNull()
Returns a predicate which returns false if the input is null,
true otherwise.
|
static <A,B> Predicate<A> |
notNull(Function<A,? extends B> composeFunction)
Returns a predicate which takes the input, passes it through the given
function, and then evaluates the result against
notNull(). |
public static <A,B> Predicate<A> compose(Function<A,? extends B> function, Predicate<B> predicate)
A - the input typeB - the tested typefunction - the function to map the inputpredicate - the predicate to test the result of the mappingpublic static <T> Predicate<T> alwaysTrue()
T - the typepublic static <T> Predicate<T> alwaysFalse()
T - the typepublic static <T> Predicate<T> isNull()
T - the typepublic static <A,B> Predicate<A> isNull(Function<A,? extends B> composeFunction)
isNull().A - the input typeB - the tested typecomposeFunction - the function to map the inputpublic static <T> Predicate<T> notNull()
T - the typepublic static <A,B> Predicate<A> notNull(Function<A,? extends B> composeFunction)
notNull().A - the input typeB - the tested typecomposeFunction - the function to map the inputpublic static <T> Predicate<T> equalTo(@Nullable Object target)
Object.equals(Object) to the input. If the target is null,
the predicate returns true if the input is also null, false otherwise.T - the typetarget - the target object to compare againstpublic static <A,B> Predicate<A> equalTo(Function<A,? extends B> composeFunction, @Nullable Object target)
equalTo(Object).A - the input typeB - the tested typecomposeFunction - the function to map the inputtarget - the target object to compare againstpublic static <T> Predicate<T> in(Collection<? extends T> collection)
T - the typecollection - the collection to querypublic static <A,B> Predicate<A> in(Function<A,? extends B> composeFunction, Collection<? extends B> collection)
in(Collection).A - the input typeB - the tested typecomposeFunction - the function to map the inputcollection - the collection to query@SafeVarargs public static <T> Predicate<T> in(T... args)
T - the typeargs - the array to query@SafeVarargs public static <A,B> Predicate<A> in(Function<A,? extends B> composeFunction, B... args)
in(Object[]).A - the input typeB - the tested typecomposeFunction - the function to map the inputargs - the array to querypublic static <T> Predicate<T> instanceOf(Class<?> clazz)
T - the typeclazz - the classpublic static <A,B> Predicate<A> instanceOf(Function<A,? extends B> composeFunction, Class<?> clazz)
instanceOf(Class).A - the input typeB - the tested typecomposeFunction - the function to map the inputclazz - the classCopyright © 2022. All rights reserved.