EA-254537: Plow.mapNotNull added and used

GitOrigin-RevId: 8c34a6310781ebecc413ef3e73963a4a861f30f2
This commit is contained in:
Nicolay Mitropolsky
2021-04-06 20:21:38 +00:00
committed by intellij-monorepo-bot
parent 1ccb5ea4e3
commit 7c5adeccc8
@@ -42,6 +42,8 @@ class Plow<T> private constructor(private val producingFunction: (Processor<T>)
Plow { pr -> producingFunction(transformation(pr)) }
fun <R> map(mapping: (T) -> R): Plow<R> = transform { pr -> Processor { v -> pr.process(mapping(v)) } }
fun <R> mapNotNull(mapping: (T) -> R?): Plow<R> = transform { pr -> Processor { v -> mapping(v)?.let { pr.process(it) } ?: true } }
fun filter(test: (T) -> Boolean): Plow<T> = transform { pr -> Processor { v -> !test(v) || pr.process(v) } }