atrium-domain-builders-jvm / ch.tutteli.atrium.domain.builders.utils / ArgumentToNullOrMapperBuilder

ArgumentToNullOrMapperBuilder

class ArgumentToNullOrMapperBuilder<T : Any> (source)

Builder to map variable length arguments formulated as (first: T, vararg others : T) to something else.

Its usage is intended to turn the nullable argument type of the given argumentMapperBuilder into its non-nullable type if the argument is not null in order that the non-nullable type can be used/passed to function which expect a non-nullable type.

Constructors

<init>

ArgumentToNullOrMapperBuilder(argumentMapperBuilder: ArgumentMapperBuilder<T?>)

Builder to map variable length arguments formulated as (first: T, vararg others : T) to something else.

Properties

argumentMapperBuilder

val argumentMapperBuilder: ArgumentMapperBuilder<T?>

Functions

toAssert

fun <R : Any> toAssert(assertionCreator: <ERROR CLASS><R>.(T) -> Unit): Pair<(<ERROR CLASS><R>.() -> Unit)?, Array<(<ERROR CLASS><R>.() -> Unit)?>>

Maps each argument to null if it is already null and if not, then to an AssertionPlantNullable<R> lambda with receiver by using the given assertionCreator (passing in the argument).

toExpect

fun <R : Any> toExpect(assertionCreator: <ERROR CLASS><R>.(T) -> Unit): Pair<(<ERROR CLASS><R>.() -> Unit)?, Array<(<ERROR CLASS><R>.() -> Unit)?>>

Maps each argument to null if it is already null and if not, then to an Expect<R> lambda with receiver by using the given assertionCreator (passing in the argument).

Extension Functions

asExpect

fun <T, A> A.asExpect(): <ERROR CLASS><T>
fun <T : Any, A> A.asExpect(assertionCreator: <ERROR CLASS><T>.() -> Unit): A

Turns Assert or AssertionPlantNullable into an Expect so that you can use new functionality which is not available on Assert/AssertionPlantNullable.