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

Predicates

class Predicates

A collection of predefined general-purpose Predicate implementations.

Functions

allOf

static fun <T : Any!> allOf(vararg predicates: Predicate<T>!): Predicate<T>!

Returns a predicate that will return true if all given predicates return true. Please be aware that an empty array of predicates will cause this function to return true.

alwaysFalse

static fun <T : Any!> alwaysFalse(): Predicate<T>!

Returns a predicate that will always return false for any passed value.

alwaysTrue

static fun <T : Any!> alwaysTrue(): Predicate<T>!

Returns a predicate that will always return true for any passed value.

anyOf

static fun <T : Any!> anyOf(vararg predicates: Predicate<T>!): Predicate<T>!

Returns a predicate that will return true if one of the given predicates returns true.

failWith

static fun <T : Any!, C : RuntimeException!> failWith(exception: C): Predicate<T>!
static fun <T : Any!, C : RuntimeException!> failWith(exception: Class<C>): Predicate<T>!

Returns a predicate that will fail with a given RuntimeException. This method is useful for testing other code that is using predicates and how it handles exceptional situations.

instanceOf

static fun <R : Any!, T : Any!> instanceOf(type: Class<T>): Predicate<R>!

Returns a predicate checking if value is instance of the given type.

is

static fun <T : Any!> is(value: T): Predicate<T>!

Returns a predicate checking if the given value is the same as passed one.

isNot

static fun <T : Any!> isNot(value: T): Predicate<T>!

Returns a predicate checking if the given value is not the same as passed one.

isNotNull

static fun <T : Any!> isNotNull(): Predicate<T>!

Returns a predicate checking if given value is not null.

isNull

static fun <T : Any!> isNull(): Predicate<T>!

Returns a predicate checking if given value is null.

noneOf

static fun <T : Any!> noneOf(vararg predicates: Predicate<T>!): Predicate<T>!

Returns a predicate that will return true if none of the given predicates returns true.