Fix select.kt

This commit is contained in:
Alexander Nozik 2022-04-17 22:21:11 +03:00
parent e5000171f1
commit 6b41163ed3
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357

View File

@ -35,10 +35,12 @@ private fun <R : Any> Data<*>.castOrNull(type: KType): Data<R>? =
public fun <R : Any> DataSet<*>.select(
type: KType,
namePattern: Name? = null,
filter: (name: Name, meta: Meta) -> Boolean = { _, _ -> true }
filter: (name: Name, meta: Meta) -> Boolean = { _, _ -> true },
): ActiveDataSet<R> = object : ActiveDataSet<R> {
override val dataType = type
override val meta: Meta get() = this@select.meta
private fun checkDatum(name: Name, datum: Data<*>): Boolean = datum.type.isSubtypeOf(type)
&& (namePattern == null || name.matches(namePattern))
&& filter(name, datum.meta)
@ -65,7 +67,7 @@ public fun <R : Any> DataSet<*>.select(
*/
public inline fun <reified R : Any> DataSet<*>.select(
namePattern: Name? = null,
noinline filter: (name: Name, meta: Meta) -> Boolean = { _, _ -> true }
noinline filter: (name: Name, meta: Meta) -> Boolean = { _, _ -> true },
): DataSet<R> = select(typeOf<R>(), namePattern, filter)
/**