Predicate

Added in 1.2.0

public interface Predicate<T>


Compat version of java.util.function.Predicate

Parameters
<T>

the type of the input to the operation

Summary

Public methods

default Predicate<T>

Returns a composed predicate that represents a short-circuiting logical AND of this predicate and another.

default static Predicate<T>
<T> isEqual(Object targetRef)

Returns a predicate that tests if two arguments are equal according to equals.

default Predicate<T>

Returns a predicate that represents the logical negation of this predicate.

default static Predicate<T>
<T> not(Predicate<Object> target)

Returns a predicate that is the negation of the supplied predicate.

default Predicate<T>

Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another.

abstract boolean
test(T t)

Evaluates this predicate on the given argument.

Public methods

and

default Predicate<T> and(Predicate<Object> other)

Returns a composed predicate that represents a short-circuiting logical AND of this predicate and another. When evaluating the composed predicate, if this predicate is false, then the other predicate is not evaluated.

Any exceptions thrown during evaluation of either predicate are relayed to the caller; if evaluation of this predicate throws an exception, the other predicate will not be evaluated.

Parameters
Predicate<Object> other

a predicate that will be logically-ANDed with this predicate

Returns
Predicate<T>

a composed predicate that represents the short-circuiting logical AND of this predicate and the other predicate

Throws
java.lang.NullPointerException

if other is null

isEqual

Added in 1.9.0
default static Predicate<T> <T> isEqual(Object targetRef)

Returns a predicate that tests if two arguments are equal according to equals.

Parameters
<T>

the type of arguments to the predicate

Object targetRef

the object reference with which to compare for equality, which may be null

Returns
Predicate<T>

a predicate that tests if two arguments are equal according to equals

negate

Added in 1.9.0
default Predicate<T> negate()

Returns a predicate that represents the logical negation of this predicate.

Returns
Predicate<T>

a predicate that represents the logical negation of this predicate

not

default static Predicate<T> <T> not(Predicate<Object> target)

Returns a predicate that is the negation of the supplied predicate. This is accomplished by returning result of the calling target.negate().

11

Parameters
<T>

the type of arguments to the specified predicate

Predicate<Object> target

predicate to negate

Returns
Predicate<T>

a predicate that negates the results of the supplied predicate

Throws
java.lang.NullPointerException

if target is null

or

default Predicate<T> or(Predicate<Object> other)

Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another. When evaluating the composed predicate, if this predicate is true, then the other predicate is not evaluated.

Any exceptions thrown during evaluation of either predicate are relayed to the caller; if evaluation of this predicate throws an exception, the other predicate will not be evaluated.

Parameters
Predicate<Object> other

a predicate that will be logically-ORed with this predicate

Returns
Predicate<T>

a composed predicate that represents the short-circuiting logical OR of this predicate and the other predicate

Throws
java.lang.NullPointerException

if other is null

test

Added in 1.2.0
abstract boolean test(T t)

Evaluates this predicate on the given argument.

Parameters
T t

the input argument

Returns
boolean

true if the input argument matches the predicate, otherwise false