[fleet] deprecating ServiceEntity<*>

GitOrigin-RevId: d26dd7e0cc2e2c5a4fd35a466e997e5fb9bf7611
This commit is contained in:
Alexander Shparun
2024-09-16 17:57:14 +02:00
committed by intellij-monorepo-bot
parent 4bed7454d8
commit ecc3d78a3a

View File

@@ -3,7 +3,6 @@ package fleet.util
import fleet.util.logging.KLogger
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.transformWhile
@@ -31,6 +30,9 @@ fun <T, K> Iterable<T>.associateByUnique(keySelector: (T) -> K): Map<K, T> =
}
}
/**
* Same idea as [kotlin.collections.singleOrNull] but will throw if the collection contains more than one element.
* */
inline fun <T> Iterable<T>.singleOrNullOrThrow(p: (T) -> Boolean = { true }): T? {
var single: T? = null
var found = false