From 7c5adeccc8cb7f9e996098420de3d807a2afcaef Mon Sep 17 00:00:00 2001 From: Nicolay Mitropolsky Date: Tue, 6 Apr 2021 22:43:47 +0300 Subject: [PATCH] EA-254537: `Plow.mapNotNull` added and used GitOrigin-RevId: 8c34a6310781ebecc413ef3e73963a4a861f30f2 --- platform/util-ex/src/com/intellij/util/Plow.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/util-ex/src/com/intellij/util/Plow.kt b/platform/util-ex/src/com/intellij/util/Plow.kt index 0ab918673ebe..120b80815eb6 100644 --- a/platform/util-ex/src/com/intellij/util/Plow.kt +++ b/platform/util-ex/src/com/intellij/util/Plow.kt @@ -42,6 +42,8 @@ class Plow private constructor(private val producingFunction: (Processor) Plow { pr -> producingFunction(transformation(pr)) } fun map(mapping: (T) -> R): Plow = transform { pr -> Processor { v -> pr.process(mapping(v)) } } + + fun mapNotNull(mapping: (T) -> R?): Plow = transform { pr -> Processor { v -> mapping(v)?.let { pr.process(it) } ?: true } } fun filter(test: (T) -> Boolean): Plow = transform { pr -> Processor { v -> !test(v) || pr.process(v) } }