sdk-common / com.tomtom.online.sdk.common.functional / Predicate

Predicate

@FunctionalInterface interface Predicate<T : Any!>

Represents a predicate (boolean-valued function) of one argument.

Functions

and

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

Performs a predicate composition returning a "short-circuit logical AND" of this predicate and another. Please note that first predicate to get evaluated is this predicate. If it returns false then the other predicate will not get 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.

equivalence

open fun equivalence(other: Predicate<T>): Predicate<T>!

Performs a predicate composition returning a "boolean equality". This operation will result with a predicate returning true if two composed predicates return the same value (both give true / both give false).

not

open fun not(): Predicate<T>!

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

or

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

Performs a predicate composition returning a "short-circuit logical OR" of this predicate and another. Please note that the first predicate to get evaluated is "this" predicate. If it returns true then the other predicate will not get 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.

test

abstract fun test(value: T): Boolean

Evaluates this predicate on the given argument.

then

open fun then(other: Predicate<T>): Predicate<T>!

Performs a predicate composition returning a "logical material implication". If p is true then the value of p -> q is taken to be that of q. But if p is false then true is returned.

toFunction

open fun toFunction(): ((T) -> Boolean!)!

Performs a conversion to a Function1 in case a predicate needs to be used in a function context.

xor

open fun xor(other: Predicate<T>): Predicate<T>!

Performs a predicate composition returning a "logical eXclusive OR". This operation will result with a predicate returning true if two composed predicates differ (one is true, the other is false).