ru.hnau.jutils.producer.extensions.long.producerExtensionsLong.kt Maven / Gradle / Ivy
package ru.hnau.jutils.producer.extensions.long
import ru.hnau.jutils.*
import ru.hnau.jutils.producer.Producer
import ru.hnau.jutils.producer.extensions.filter
fun Producer.callIfZero() = callIf { it == 0L }
fun Producer.filterPositive() = filter { it > 0 }
fun Producer.filterNegative() = filter { it < 0 }
fun Producer.filterNotPositive() = filter { it <= 0 }
fun Producer.filterNotNegative() = filter { it >= 0 }
fun Producer.coerceAtLeast(minimumValue: Long) =
map { it.coerceAtLeast(minimumValue) }
fun Producer.coerceAtMost(maximumValue: Long) =
map { it.coerceAtMost(maximumValue) }
fun Producer.coerceIn(range: ClosedFloatingPointRange) =
map { it.coerceIn(range) }
fun Producer.coerceIn(range: ClosedRange) =
map { it.coerceIn(range) }
fun Producer.coerceIn(minimumValue: Long, maximumValue: Long) =
map { it.coerceIn(minimumValue, maximumValue) }
fun Producer.toBoolean() = map(Long::toBoolean)
fun Producer.toInt() = map(Long::toInt)
fun Producer.toLong() = map(Long::toLong)
fun Producer.toByte() = map(Long::toByte)
fun Producer.toShort() = map(Long::toShort)
fun Producer.toFloat() = map(Long::toFloat)
fun Producer.toDouble() = map(Long::toDouble)
operator fun Producer.unaryPlus() = map(Long::unaryPlus)
operator fun Producer.unaryMinus() = map(Long::unaryMinus)
operator fun Producer.inc() = map(Long::inc)