public final class PredicateUtil
extends java.lang.Object
Predicate-related utility methods.| Modifier and Type | Method and Description |
|---|---|
static Predicate<java.lang.Object> |
after(long expirationTime)
Returns a
Predicate<Object> that evaluates to true iff the current time is after the given
expiration time. |
static <T> Predicate<T> |
always() |
static <T> Predicate<T> |
and(Predicate<? super T> p1,
Predicate<? super T> p2)
|
static <T,EX extends java.lang.RuntimeException> |
asPredicate(PredicateWhichThrows<T,EX> source)
Converts a
PredicateWhichThrows into a Predicate, which is possible iff the source's exception
is a subclass of RuntimeException and the source's element type is a subclass of the target's element
type. |
static <T,EX extends java.lang.Throwable> |
asPredicateWhichThrows(Predicate<? super T> source)
Converts a
Predicate into a PredicateWhichThrows, which is possible iff the source's element
type is a subclass of the target's element type. |
static <C extends java.lang.Comparable<C>> |
between(C min,
C max) |
static <T> Predicate<T> |
contains(java.util.Collection<? extends T> collection) |
static <K> Predicate<K> |
containsKey(java.util.Map<K,?> map) |
static <K> Predicate<K> |
containsKey(Mapping<K,?> mapping) |
static <C extends java.lang.Comparable<C>> |
equal(C other) |
static <T> Predicate<T> |
equals(T other)
Value equality.
|
static <T extends Predicate<java.lang.String>> |
forString(java.lang.String format,
T delegate)
Returns a predicate that evaluates the
format against the delegate after each "*" in the format has been replaced with the subject. |
static <C extends java.lang.Comparable<C>> |
greater(C other) |
static <C extends java.lang.Comparable<C>> |
greaterEqual(C other) |
static <C extends java.lang.Comparable<C>> |
less(C other) |
static <C extends java.lang.Comparable<C>> |
lessEqual(C other) |
static <T> Predicate<T> |
never() |
static <T> Predicate<T> |
not(Predicate<? super T> delegate) |
static <C extends java.lang.Comparable<C>> |
notEqual(C other) |
static <T> Predicate<T> |
notEquals(T other)
Value inequality.
|
static <T> Predicate<T> |
or(Predicate<? super T> p1,
Predicate<? super T> p2) |
public static <T> Predicate<T> always()
Predicate who's Predicate.evaluate(Object) method always returns true.public static <T> Predicate<T> never()
Predicate who's Predicate.evaluate(Object) method always returns false.public static <T> Predicate<T> or(Predicate<? super T> p1, Predicate<? super T> p2)
Predicate which returns true if p1 or p2 returns true
for a given subject.public static <T> Predicate<T> not(Predicate<? super T> delegate)
Predicate which returns true iff the delegate returns false for any
given subject.public static <C extends java.lang.Comparable<C>> Predicate<C> less(C other)
Predicate which returns true iff a given subject is less than the
other.public static <C extends java.lang.Comparable<C>> Predicate<C> lessEqual(C other)
Predicate which returns true iff a given subject is less than or equal to the
other.public static <C extends java.lang.Comparable<C>> Predicate<C> greater(C other)
Predicate which returns true iff a given subject is greater than the
other.public static <C extends java.lang.Comparable<C>> Predicate<C> greaterEqual(C other)
Predicate which returns true iff a given subject is greater than or equal to
the other.public static <C extends java.lang.Comparable<C>> Predicate<C> equal(C other)
Predicate which returns true iff a given subject is (arithmetically) equal
to the other.public static <C extends java.lang.Comparable<C>> Predicate<C> notEqual(C other)
Predicate which returns true iff a given subject is (arithmetically) not equal
to the other.public static <C extends java.lang.Comparable<C>> Predicate<C> between(C min, C max)
min <= subject <= max, or, if min > max: subject >= min || subject <= maxpublic static <T> Predicate<T> equals(T other)
public static <T> Predicate<T> notEquals(T other)
public static Predicate<java.lang.Object> after(long expirationTime)
Predicate<Object> that evaluates to true iff the current time is after the given
expiration time.
(The returned predicate ignores its subject argument.)
public static <T extends Predicate<java.lang.String>> T forString(java.lang.String format, T delegate)
format against the delegate after each "*" in the format has been replaced with the subject.
withpublic static <T,EX extends java.lang.Throwable> PredicateWhichThrows<T,EX> asPredicateWhichThrows(Predicate<? super T> source)
Predicate into a PredicateWhichThrows, which is possible iff the source's element
type is a subclass of the target's element type.T - The subject typeEX - The target predicate's exceptionpublic static <T,EX extends java.lang.RuntimeException> Predicate<T> asPredicate(PredicateWhichThrows<T,EX> source)
PredicateWhichThrows into a Predicate, which is possible iff the source's exception
is a subclass of RuntimeException and the source's element type is a subclass of the target's element
type.T - The predicate subject typeEX - The source predicate's exceptionpublic static <T> Predicate<T> contains(java.util.Collection<? extends T> collection)
collection contains the subjectpublic static <K> Predicate<K> containsKey(java.util.Map<K,?> map)
Predicate that evaluates to true iff the map contains a key equal to the
predicate subject