fr.stardustenterprises.stargrad.dsl.other.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stargrad Show documentation
Show all versions of stargrad Show documentation
Common library for our gradle plugins.
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