ru.hnau.jutils.TakeUtils.kt Maven / Gradle / Ivy
package ru.hnau.jutils
fun > T.takeIfLargeThan(other: T) = takeIf { it > other }
fun > T.takeIfLessThan(other: T) = takeIf { it < other }
fun Byte.takeIfPositive() = takeIf { it > 0 }
fun Byte.takeIfNegative() = takeIf { it < 0 }
fun Byte.takeIfZeroOrPositive() = takeIf { it >= 0 }
fun Byte.takeIfZeroOrNegative() = takeIf { it <= 0 }
fun Int.takeIfPositive() = takeIf { it > 0 }
fun Int.takeIfNegative() = takeIf { it < 0 }
fun Int.takeIfZeroOrPositive() = takeIf { it >= 0 }
fun Int.takeIfZeroOrNegative() = takeIf { it <= 0 }
fun Long.takeIfPositive() = takeIf { it > 0 }
fun Long.takeIfNegative() = takeIf { it < 0 }
fun Long.takeIfZeroOrPositive() = takeIf { it >= 0 }
fun Long.takeIfZeroOrNegative() = takeIf { it <= 0 }
fun Float.takeIfPositive() = takeIf { it > 0 }
fun Float.takeIfNegative() = takeIf { it < 0 }
fun Float.takeIfZeroOrPositive() = takeIf { it >= 0 }
fun Float.takeIfZeroOrNegative() = takeIf { it <= 0 }
fun Double.takeIfPositive() = takeIf { it > 0 }
fun Double.takeIfNegative() = takeIf { it < 0 }
fun Double.takeIfZeroOrPositive() = takeIf { it >= 0 }
fun Double.takeIfZeroOrNegative() = takeIf { it <= 0 }
fun List.takeIfEmpty() = takeIf(List::isEmpty)
fun List.takeIfNotEmpty() = takeIf(List::isNotEmpty)
fun Array.takeIfEmpty() = takeIf(Array::isEmpty)
fun Array.takeIfNotEmpty() = takeIf(Array::isNotEmpty)
fun String.takeIfEmpty() = takeIf(String::isEmpty)
fun String.takeIfNotEmpty() = takeIf(String::isNotEmpty)
fun String.takeIfBlank() = takeIf(String::isBlank)
fun String.takeIfNotBlank() = takeIf(String::isNotBlank)
fun Boolean.takeIfTrue() = if (this) this else null
fun Boolean.takeIfFalse() = if (!this) this else null