mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
[fleet, rhizomedb] Yet another util function
GitOrigin-RevId: 9a1d34a9a1feb5edb313df4c75432fcdcdbfae81
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4123a5154e
commit
401febfb7f
@@ -148,6 +148,12 @@ fun predicateQuery(p: () -> Boolean): Query<Unit> = queryOf(Unit).filter { p() }
|
||||
fun <T> Query<T>.filter(p: (T) -> Boolean): Query<T> =
|
||||
flatMap { t -> if (p(t)) setOf(t) else emptySet() }
|
||||
|
||||
/**
|
||||
* Returns a query containing only matches of the original query that are instances of specified type parameter [R].
|
||||
* */
|
||||
inline fun <reified R> Query<*>.filterIsInstance(): Query<R> =
|
||||
flatMap { t -> if (t is R) setOf(t) else emptySet() }
|
||||
|
||||
/**
|
||||
* version of [filter] working with [Match]
|
||||
* [p] has to be a *pure* function of a database
|
||||
|
||||
Reference in New Issue
Block a user