whatif / com.skydoves.whatif

Package com.skydoves.whatif

Extensions for External Classes

kotlin.Any

kotlin.Array

kotlin.Boolean

kotlin.BooleanArray

kotlin.ByteArray

kotlin.CharArray

kotlin.DoubleArray

kotlin.FloatArray

kotlin.IntArray

kotlin.LongArray

kotlin.ShortArray

kotlin.collections.List

kotlin.collections.Map

kotlin.collections.Set

Functions

whatIf

fun <T> T.whatIf(given: (T) -> Boolean?, whatIf: () -> Unit): Unit

An expression for invoking whatIf when the given boolean is true.

fun <T> T.whatIf(given: (T) -> Boolean?, whatIf: () -> Unit, whatIfNot: () -> Unit): Unit

An expression for invoking whatIf when the given boolean is true. If the given boolean is false, whatIfNotNull will be invoked instead of the whatIf.

fun <T> T.whatIf(given: Boolean?, whatIf: T.() -> Unit): T

An expression for invoking whatIf when the given boolean is true. So it is useful when using with a chaining function like builder pattern or apply expression in kotlin.

fun <T> T.whatIf(given: Boolean?, whatIf: T.() -> Unit, whatIfNot: T.() -> Unit): T

An expression for invoking whatIf when the given boolean is true. If the given boolean is false, whatIfNotNull will be invoked instead of the whatIf. So it is useful when using with a chaining function like builder pattern or apply expression in kotlin.

fun <T> T.whatIf(given: () -> Boolean?, whatIfDo: T.() -> Unit): T

An expression for invoking whatIf when the given lambda's return value is true. So it is useful when using with a chaining function like builder pattern or apply expression in kotlin.

fun <T> T.whatIf(given: () -> Boolean?, whatIfDo: T.() -> Unit, whatIfNot: T.() -> Unit): T

An expression for invoking whatIf when the given lambda's return value is true. If the given boolean is false, whatIfNotNull will be invoked instead of the whatIf. So it is useful when using with a chaining function like builder pattern or apply expression in kotlin.

whatIfLet

fun <T, R> T.whatIfLet(given: Boolean?, default: R, whatIf: (T) -> R): R

An expression for invoking whatIf when the given boolean value. If the given boolean value is false, the result value is the default. It is useful when the receiver T and the result R should be different.

fun <T, R> T.whatIfLet(given: Boolean?, whatIf: (T) -> R, whatIfNot: (T) -> R): R

An expression for invoking whatIf when the given boolean value. If the given boolean is false, whatIfNotNull will be invoked instead of the whatIf. It is useful when the receiver T and the result R should be different.

whatIfNotNull

fun <T> T?.whatIfNotNull(whatIf: (T) -> Unit): Unit

An expression for invoking whatIf when the T target object is not null.

fun <T> T?.whatIfNotNull(whatIf: (T) -> Unit, whatIfNot: (T?) -> Unit): Unit

An expression for invoking whatIf when the T target object is not null. If the T target is null, whatIfNot will be invoked instead of the whatIf.

whatIfNotNullWith

fun <T, R> T?.whatIfNotNullWith(whatIf: (T) -> R, whatIfNot: (T?) -> R): R

An expression for invoking whatIf when the T target object is not null. If the T target is null, whatIfNot will be invoked instead of the whatIf. It is useful when the receiver T and the result R should be different.