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

fr.stardustenterprises.stargrad.dsl.other.kt Maven / Gradle / Ivy

The newest version!
@file:Suppress("unused")

package fr.stardustenterprises.stargrad.dsl

/**
 * Applies the given [block] if the [if] value is true, only return the
 * object itself if not.
 *
 * @param if Whether the block should be applied.
 * @param block The block to be applied.
 *
 * @return This instance.
 */
inline fun  T.applyIf(`if`: Boolean, block: T.() -> Unit): T =
    apply { if (`if`) { this.apply(block) } }

/**
 * Applies the given [block] if the [ifPredicate] results to true, only return
 * the object itself if not.
 *
 * @param ifPredicate Results to whether the block should be applied.
 * @param block The block to be applied.
 *
 * @return This instance.
 */
inline fun  T.applyIf(
    ifPredicate: T.() -> Boolean,
    block: T.() -> Unit
): T = applyIf(ifPredicate(this), block)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy