11 lines
336 B
Kotlin
11 lines
336 B
Kotlin
package com.adlerosn.brasilfurfest.helper
|
|
|
|
fun <T> T?.nullIf(condition: (T)->Boolean): T? =
|
|
if (this?.let { condition(this) } != false)
|
|
null
|
|
else
|
|
this
|
|
|
|
fun <T> T?.nullIfNot(condition: (T)->Boolean): T? = nullIf { condition(it).not() }
|
|
|
|
fun String?.nullIfBlank(): String? = nullIf { it.isBlank() } |