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)
Deprecated.
Use "
PredicateUtil.ignoreSubject(ProducerUtil.after(expirationTime))" instead |
static <T> Predicate<T> |
always() |
static <T> Predicate<T> |
always(boolean value) |
static <T> Predicate<T> |
and(boolean lhs,
Predicate<? super T> rhs)
|
static <T> Predicate<T> |
and(Predicate<? super T> lhs,
boolean rhs)
|
static <T> Predicate<T> |
and(Predicate<? super T> lhs,
Predicate<? super T> rhs)
|
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 <T> Predicate<T> |
atMostEvery(long milliseconds)
Deprecated.
Use "
PredicateUtil.ignoreSubject(ProducerUtil.atMostEvery(milliseconds))" instead |
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, as opposed to arithmetical 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 <T,EX extends java.lang.Throwable> |
ignoreExceptions(java.lang.Class<EX> exceptionClass,
PredicateWhichThrows<T,EX> delegate,
boolean defaultValue)
Wraps the delegate such that its declared exception is caught, ignored, and the
defaultValue is returned.
|
static <T,EX extends java.lang.Throwable> |
ignoreSubject(Producer<java.lang.Boolean> delegate) |
static <T,EX extends java.lang.Throwable> |
ignoreSubject(ProducerWhichThrows<java.lang.Boolean,EX> delegate) |
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(boolean value)
|
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(boolean lhs,
Predicate<? super T> rhs)
Returns a
Predicate which evaluates to true if the lhs is true, or the
rhs evaluates to true, or both. |
static <T> Predicate<T> |
or(Predicate<? super T> lhs,
boolean rhs)
|
static <T> Predicate<T> |
or(Predicate<? super T> lhs,
Predicate<? super T> rhs)
|
static <T> Predicate<T> |
xor(boolean lhs,
Predicate<? super T> rhs) |
static <T> Predicate<T> |
xor(Predicate<? super T> lhs,
boolean rhs) |
static <T> Predicate<T> |
xor(Predicate<? super T> lhs,
Predicate<? super T> rhs) |
public static <T> Predicate<T> always(boolean value)
Predicate which evaluates to the value (regardless of the subject)public static <T> Predicate<T> always()
Predicate which evaluates to true (regardless of the subject)public static <T> Predicate<T> never()
Predicate which evaluates to false (regardless of the subject)@Deprecated public static <T> Predicate<T> atMostEvery(long milliseconds)
PredicateUtil.ignoreSubject(ProducerUtil.atMostEvery(milliseconds))" insteadPredicate for which the first evaluation will yield true, and,
after that, the time interval between adjacent true evaluations will (A) be minimal and (B) never
shorter than milliseconds.public static <T> Predicate<T> and(Predicate<? super T> lhs, boolean rhs)
Predicate which evaluates to true iff both the rhs is true
and the lhs evaluates to true.
Notice that iff the rhs is false, then the lhs will ever be evaluated.
public static <T> Predicate<T> and(boolean lhs, Predicate<? super T> rhs)
Predicate which evaluates to true iff both the lhs is true and
the rhs evaluates to true.
Notice that iff the lhs is false, then the rhs will ever be evaluated.
public static <T> Predicate<T> or(Predicate<? super T> lhs, boolean rhs)
Predicate which evaluates to true the lhs evaluates to true, or the
rhs is true, or both.
Notice that iff the rhs is true, then the lhs will ever be evaluated.
public static <T> Predicate<T> or(boolean lhs, Predicate<? super T> rhs)
Predicate which evaluates to true if the lhs is true, or the
rhs evaluates to true, or both.
Notice that iff the lhs is true, then the rhs will ever be evaluated.
public static <T> Predicate<T> xor(Predicate<? super T> lhs, Predicate<? super T> rhs)
Predicate which evaluates to true iff exactly one of lhs or
rhs evaluate to truepublic static <T> Predicate<T> xor(Predicate<? super T> lhs, boolean rhs)
Predicate which evaluates to true iff either the lhs evaluates to true and rhs is false, or the lhs evaluates to false and
rhs is truepublic static <T> Predicate<T> xor(boolean lhs, Predicate<? super T> rhs)
Predicate which evaluates to true iff either lhs is true and the
rhs evaluates to false, or the lhs is false and the
rhs evaluates to truepublic static <T> Predicate<T> not(Predicate<? super T> delegate)
Predicate which evaluates to true iff the delegate evaluates to falsepublic static <T> Predicate<T> not(boolean value)
Predicate which evaluates to the negation of the value (regardless of the subject)public static <C extends java.lang.Comparable<C>> Predicate<C> less(C other)
Predicate which evaluates to true for any subject that is less than the
otherpublic static <C extends java.lang.Comparable<C>> Predicate<C> lessEqual(C other)
Predicate which evaluates to true for any given subject that is less than or
equal to the otherpublic static <C extends java.lang.Comparable<C>> Predicate<C> greater(C other)
Predicate which evaluates to true for any given subject that is greater
than the otherpublic static <C extends java.lang.Comparable<C>> Predicate<C> greaterEqual(C other)
Predicate which evaluates to true for any given subject that is greater
than or equal to the otherpublic static <C extends java.lang.Comparable<C>> Predicate<C> equal(C other)
Predicate which evaluates to true for any given
subject that is (arithmetically) equal to the otherComparable.compareTo(Object)public static <C extends java.lang.Comparable<C>> Predicate<C> notEqual(C other)
Predicate which evaluates to true for any given
subject that is (arithmetically) not equal to the otherComparable.compareTo(Object)public static <C extends java.lang.Comparable<C>> Predicate<C> between(C min, C max)
<= subject <= max", or, if
min > max, to "subject >= min ||
subject <= max"public static <T> Predicate<T> equals(T other)
equal(Comparable)public static <T> Predicate<T> notEquals(T other)
@Deprecated public static Predicate<java.lang.Object> after(long expirationTime)
PredicateUtil.ignoreSubject(ProducerUtil.after(expirationTime))" insteadPredicate<Object>" that evaluates to true iff the current time is after the
given expirationTime (in milliseconds).
(The returned predicate ignores its subject argument.)
expirationTime - Milliseconds since Jan 1 1970, UTCpublic static <T extends Predicate<java.lang.String>> T forString(java.lang.String format, T delegate)
public 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)
public 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 subjectpublic static <K> Predicate<K> containsKey(Mapping<K,?> mapping)
Predicate that evaluates to true iff the mapping contains a key equal to the
predicate subjectpublic static <T,EX extends java.lang.Throwable> PredicateWhichThrows<T,EX> ignoreSubject(ProducerWhichThrows<java.lang.Boolean,EX> delegate)
public static <T,EX extends java.lang.Throwable> Predicate<T> ignoreSubject(Producer<java.lang.Boolean> delegate)
public static <T,EX extends java.lang.Throwable> Predicate<T> ignoreExceptions(java.lang.Class<EX> exceptionClass, PredicateWhichThrows<T,EX> delegate, boolean defaultValue)