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

tech.figure.classification.asset.util.extensions.GenericExtensions.kt Maven / Gradle / Ivy

Go to download

Various tools for interacting with the Asset Classification smart contract

There is a newer version: 3.10.0
Show newest version
package tech.figure.classification.asset.util.extensions

/**
 * All extensions in this library are suffixed with "Ac" to ensure they do not overlap with other libraries' extensions.
 */

/**
 * The functional equivalent of an elvis operator, allowing default values to be derived when an elvis operator
 * would cause weird-looking syntax, like parenthetical enclosures that unnecessarily obfuscate meaning.
 */
fun  T?.elvisAc(default: () -> T): T = this ?: default()

/**
 * Functionally identical to Kotlin Stdlib's .also extension function, except that the logic will only execute if the
 * condition value is passed as 'true'.
 */
fun  T.alsoIfAc(condition: Boolean, action: () -> Unit): T = this.also {
    if (condition) {
        action.invoke()
    }
}

fun  T.wrapListAc(): List = listOf(this)

fun  T.wrapSetAc(): Set = setOf(this)

inline fun  T.wrapArrayAc(): Array = arrayOf(this)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy