All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.github.mustafaozhan.scopemob.inCaseScope.kt Maven / Gradle / Ivy

The newest version!
/*
 Copyright (c) 2020 Mustafa Ozhan. All rights reserved.
 */
package com.github.mustafaozhan.scopemob

inline fun  T.inCase(
    condition: Boolean?,
    method: T.(T) -> Unit
): T {
    if (condition == true) {
        method(this)
    }
    return this
}

inline fun  T.inCaseNot(
    condition: Boolean?,
    method: T.(T) -> Unit
): T {
    if (condition == false) {
        method(this)
    }
    return this
}

inline fun  T.inCase(
    vararg condition: T.(T) -> Boolean?,
    method: T.(T) -> Unit
): T {
    if (condition.all { it(this) == true }) {
        method(this)
    }
    return this
}

inline fun  T.inCaseNot(
    vararg condition: T.(T) -> Boolean?,
    method: T.(T) -> Unit
): T {
    if (condition.all { it(this) == false }) {
        method(this)
    }
    return this
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy