Predicate

Added in 1.2.0

interface Predicate<T>


Compat version of java.util.function.Predicate

Parameters
<T>

the type of the input to the operation

Summary

Public functions

Predicate<T!>!
and(other: Predicate<T!>!)

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

java-static Predicate<T!>!
<T> isEqual(targetRef: Any!)

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

Predicate<T!>!

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

java-static Predicate<T!>!
<T> not(target: Predicate<T!>!)

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

Predicate<T!>!
or(other: Predicate<T!>!)

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

Boolean
test(t: T!)

Evaluates this predicate on the given argument.

Public functions

and

Added in 1.9.0
fun and(other: Predicate<T!>!): Predicate<T!>!

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
other: Predicate<T!>!

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
java-static fun <T> isEqual(targetRef: Any!): Predicate<T!>!

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

Parameters
<T>

the type of arguments to the predicate

targetRef: Any!

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
fun negate(): Predicate<T!>!

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

Added in 1.9.0
java-static fun <T> not(target: Predicate<T!>!): Predicate<T!>!

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

Parameters
<T>

the type of arguments to the specified predicate

target: Predicate<T!>!

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

Added in 1.9.0
fun or(other: Predicate<T!>!): Predicate<T!>!

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
other: Predicate<T!>!

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
fun test(t: T!): Boolean

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