From 79759c52561d503c317fd282671c4c4399ba4be3 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 22 Nov 2023 17:06:23 +0300 Subject: [PATCH] Replace `MetaProvider::getMeta` by `get` --- CHANGELOG.md | 1 + build.gradle.kts | 2 +- .../dataforge/properties/MetaProperty.kt | 5 ++- .../space/kscience/dataforge/data/DataSet.kt | 1 - .../kscience/dataforge/io/workDirectory.kt | 1 - .../space/kscience/dataforge/meta/Laminate.kt | 4 +- .../space/kscience/dataforge/meta/Meta.kt | 39 +++++-------------- .../kscience/dataforge/meta/MetaDelegate.kt | 8 ++-- .../kscience/dataforge/meta/MutableMeta.kt | 39 ++++++++----------- .../dataforge/meta/MutableMetaDelegate.kt | 12 +++--- .../kscience/dataforge/meta/ObservableMeta.kt | 2 +- .../dataforge/meta/ObservableMetaWrapper.kt | 10 ++--- .../space/kscience/dataforge/meta/Scheme.kt | 14 +++---- .../kscience/dataforge/meta/SealedMeta.kt | 6 +-- .../transformations/MetaTransformation.kt | 6 +-- 15 files changed, 63 insertions(+), 87 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f2cdff8..86a0a625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Migrated from ktor-io to kotlinx-io. - `MutableMeta` builder now returns a simplified version of meta that does not hold listeners. - More concise names for read/write methods in IO. +- Remove unnecessary confusion with `get`/`getMeta` by removing `getMeta` from the interface. ### Deprecated - `String.parseValue` is replaced with `Value.parse` diff --git a/build.gradle.kts b/build.gradle.kts index 11231531..8e55cc6f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { allprojects { group = "space.kscience" - version = "0.7.0-dev-1" + version = "0.7.0-dev-2" } subprojects { diff --git a/dataforge-context/src/commonMain/kotlin/space/kscience/dataforge/properties/MetaProperty.kt b/dataforge-context/src/commonMain/kotlin/space/kscience/dataforge/properties/MetaProperty.kt index 23601141..e79ce931 100644 --- a/dataforge-context/src/commonMain/kotlin/space/kscience/dataforge/properties/MetaProperty.kt +++ b/dataforge-context/src/commonMain/kotlin/space/kscience/dataforge/properties/MetaProperty.kt @@ -1,7 +1,8 @@ package space.kscience.dataforge.properties -import space.kscience.dataforge.meta.* +import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.meta.ObservableMutableMeta import space.kscience.dataforge.meta.transformations.MetaConverter import space.kscience.dataforge.meta.transformations.nullableMetaToObject import space.kscience.dataforge.meta.transformations.nullableObjectToMeta @@ -24,7 +25,7 @@ public class MetaProperty( override fun onChange(owner: Any?, callback: (T?) -> Unit) { meta.onChange(owner) { name -> - if (name.startsWith(this@MetaProperty.name)) callback(converter.nullableMetaToObject(get(name))) + if (name.startsWith(this@MetaProperty.name)) callback(converter.nullableMetaToObject(this[name])) } } diff --git a/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/DataSet.kt b/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/DataSet.kt index 36428cd4..44639653 100644 --- a/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/DataSet.kt +++ b/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/DataSet.kt @@ -6,7 +6,6 @@ import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.mapNotNull import space.kscience.dataforge.data.Data.Companion.TYPE_OF_NOTHING import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.set import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.endsWith diff --git a/dataforge-io/src/jvmMain/kotlin/space/kscience/dataforge/io/workDirectory.kt b/dataforge-io/src/jvmMain/kotlin/space/kscience/dataforge/io/workDirectory.kt index efdb43db..94c0e77b 100644 --- a/dataforge-io/src/jvmMain/kotlin/space/kscience/dataforge/io/workDirectory.kt +++ b/dataforge-io/src/jvmMain/kotlin/space/kscience/dataforge/io/workDirectory.kt @@ -1,7 +1,6 @@ package space.kscience.dataforge.io import space.kscience.dataforge.context.ContextBuilder -import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.set import space.kscience.dataforge.meta.string import java.nio.file.Path diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Laminate.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Laminate.kt index 966e7750..87284107 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Laminate.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Laminate.kt @@ -17,8 +17,8 @@ public class Laminate internal constructor(public val layers: List) : Type } } - override fun getMeta(name: Name): Laminate? { - val childLayers = layers.mapNotNull { it.getMeta(name) } + override fun get(name: Name): Laminate? { + val childLayers = layers.mapNotNull { it.get(name) } return if (childLayers.isEmpty()) null else Laminate(childLayers) } diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Meta.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Meta.kt index 356ef4f6..420625ca 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Meta.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Meta.kt @@ -21,9 +21,9 @@ public interface MetaRepr { * A container for meta nodes */ public fun interface MetaProvider : ValueProvider { - public fun getMeta(name: Name): Meta? + public operator fun get(name: Name): Meta? - override fun getValue(name: Name): Value? = getMeta(name)?.value + override fun getValue(name: Name): Value? = get(name)?.value } /** @@ -37,7 +37,7 @@ public interface Meta : MetaRepr, MetaProvider { public val value: Value? public val items: Map - override fun getMeta(name: Name): Meta? { + override fun get(name: Name): Meta? { tailrec fun Meta.find(name: Name): Meta? = if (name.isEmpty()) { this } else { @@ -108,21 +108,13 @@ public operator fun Meta.get(token: NameToken): Meta? = items[token] * * If [name] is empty return current [Meta] */ -public operator fun Meta?.get(name: Name): Meta? = this?.getMeta(name) - -@Deprecated("Use nullable receiver", level = DeprecationLevel.HIDDEN) -@JvmName("getNonNullable") -public operator fun Meta.get(name: Name): Meta? = getMeta(name) +public operator fun Meta?.get(name: Name): Meta? = this?.get(name) /** * Parse [Name] from [key] using full name notation and pass it to [Meta.get] */ public operator fun Meta?.get(key: String): Meta? = this?.get(key.parseAsName(true)) -@Deprecated("Use nullable receiver", level = DeprecationLevel.HIDDEN) -@JvmName("getNonNullable") -public operator fun Meta.get(key: String): Meta? = get(key.parseAsName(true)) - /** * Get all items matching given name. The index of the last element, if present is used as a [Regex], * against which indexes of elements are matched. @@ -159,7 +151,7 @@ public interface TypedMeta> : Meta { override val items: Map - override fun getMeta(name: Name): M? { + override fun get(name: Name): M? { tailrec fun M.find(name: Name): M? = if (name.isEmpty()) { this } else { @@ -182,28 +174,17 @@ public inline val > TypedMeta.self: M get() = unsafeCast() public operator fun > TypedMeta?.get(token: NameToken): M? = this?.items?.get(token) /** - * Perform recursive item search using given [name]. Each [NameToken] is treated as a name in [TypedMeta.items] of a parent node. + * Retrieves a meta node with the given name from the nullable [TypedMeta] object. * - * If [name] is empty return current [Meta] + * @param name The name of the meta node to retrieve. + * @return The meta node with the given name, or null if it doesn't exist. */ -public tailrec operator fun > TypedMeta?.get(name: Name): M? = when { - this == null -> null - name.isEmpty() -> self - else -> get(name.firstOrNull()!!)?.get(name.cutFirst()) -} - -@Deprecated("Use nullable receiver", level = DeprecationLevel.HIDDEN) -@JvmName("getNonNullable") -public operator fun > TypedMeta.get(name: Name): M? = get(name) +public operator fun > M?.get(name: Name): M? = this?.get(name) /** * Parse [Name] from [key] using full name notation and pass it to [TypedMeta.get] */ -public operator fun > TypedMeta?.get(key: String): M? = this[key.parseAsName(true)] - -@Deprecated("Use nullable receiver", level = DeprecationLevel.HIDDEN) -@JvmName("getNonNullable") -public operator fun > TypedMeta.get(key: String): M? = get(key) +public operator fun > M?.get(key: String): M? = this?.get(key.parseAsName(true)) /** diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MetaDelegate.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MetaDelegate.kt index 94b11c93..73923d56 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MetaDelegate.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MetaDelegate.kt @@ -8,28 +8,28 @@ import kotlin.properties.ReadOnlyProperty /* Meta delegates */ public fun MetaProvider.node(key: Name? = null): ReadOnlyProperty = ReadOnlyProperty { _, property -> - getMeta(key ?: property.name.asName()) + get(key ?: property.name.asName()) } public fun MetaProvider.node( key: Name? = null, converter: MetaConverter ): ReadOnlyProperty = ReadOnlyProperty { _, property -> - getMeta(key ?: property.name.asName())?.let { converter.metaToObject(it) } + get(key ?: property.name.asName())?.let { converter.metaToObject(it) } } /** * A property delegate that uses custom key */ public fun MetaProvider.value(key: Name? = null): ReadOnlyProperty = ReadOnlyProperty { _, property -> - getMeta(key ?: property.name.asName())?.value + get(key ?: property.name.asName())?.value } public fun MetaProvider.value( key: Name? = null, reader: (Value?) -> R ): ReadOnlyProperty = ReadOnlyProperty { _, property -> - reader(getMeta(key ?: property.name.asName())?.value) + reader(get(key ?: property.name.asName())?.value) } //TODO add caching for sealed nodes diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MutableMeta.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MutableMeta.kt index c5984c34..7e05d215 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MutableMeta.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MutableMeta.kt @@ -17,8 +17,8 @@ public annotation class MetaBuilderMarker * A generic interface that gives access to getting and setting meta notes and values */ public interface MutableMetaProvider : MetaProvider, MutableValueProvider { - override fun getMeta(name: Name): MutableMeta? - public fun setMeta(name: Name, node: Meta?) + override fun get(name: Name): MutableMeta? + public operator fun set(name: Name, node: Meta?) override fun setValue(name: Name, value: Value?) } @@ -37,7 +37,7 @@ public interface MutableMeta : Meta, MutableMetaProvider { */ override var value: Value? - override fun getMeta(name: Name): MutableMeta? { + override fun get(name: Name): MutableMeta? { tailrec fun MutableMeta.find(name: Name): MutableMeta? = if (name.isEmpty()) { this } else { @@ -83,11 +83,11 @@ public interface MutableMeta : Meta, MutableMetaProvider { } public infix fun Name.put(meta: Meta) { - setMeta(this, meta) + set(this, meta) } public infix fun Name.put(repr: MetaRepr) { - setMeta(this, repr.toMeta()) + set(this, repr.toMeta()) } public infix fun Name.put(builder: MutableMeta.() -> Unit) { @@ -95,7 +95,7 @@ public interface MutableMeta : Meta, MutableMetaProvider { } public infix fun String.put(meta: Meta) { - setMeta(Name.parse(this), meta) + set(Name.parse(this), meta) } public infix fun String.put(value: Value?) { @@ -123,7 +123,7 @@ public interface MutableMeta : Meta, MutableMetaProvider { } public infix fun String.put(repr: MetaRepr) { - setMeta(Name.parse(this), repr.toMeta()) + set(Name.parse(this), repr.toMeta()) } public infix fun String.putIndexed(iterable: Iterable) { @@ -135,11 +135,6 @@ public interface MutableMeta : Meta, MutableMetaProvider { } } -/** - * Set or replace node at given [name] - */ -public operator fun MutableMetaProvider.set(name: Name, meta: Meta): Unit = setMeta(name, meta) - /** * Set or replace value at given [name] */ @@ -154,24 +149,24 @@ public interface MutableTypedMeta> : TypedMeta, Mutab */ @DFExperimental public fun attach(name: Name, node: M) - override fun getMeta(name: Name): M? + override fun get(name: Name): M? override fun getOrCreate(name: Name): M } public fun > M.getOrCreate(key: String): M = getOrCreate(Name.parse(key)) public fun MutableMetaProvider.remove(name: Name) { - setMeta(name, null) + set(name, null) } public fun MutableMetaProvider.remove(key: String) { - setMeta(Name.parse(key), null) + set(Name.parse(key), null) } // node setters -public operator fun MutableMetaProvider.set(Key: NameToken, value: Meta): Unit = setMeta(Key.asName(), value) -public operator fun MutableMetaProvider.set(key: String, value: Meta): Unit = setMeta(Name.parse(key), value) +public operator fun MutableMetaProvider.set(Key: NameToken, value: Meta): Unit = set(Key.asName(), value) +public operator fun MutableMetaProvider.set(key: String, value: Meta): Unit = set(Name.parse(key), value) //public fun MutableMeta.set(key: String, index: String, value: Value?): Unit = @@ -319,7 +314,7 @@ private class MutableMetaImpl( ) @ThreadSafe - override fun setMeta(name: Name, node: Meta?) { + override fun set(name: Name, node: Meta?) { val oldItem: ObservableMutableMeta? = get(name) if (oldItem != node) { when (name.length) { @@ -346,7 +341,7 @@ private class MutableMetaImpl( newNode.adoptBy(this, token) children[token] = newNode } - items[token]?.setMeta(name.cutFirst(), node) + items[token]?.set(name.cutFirst(), node) } } invalidate(name) @@ -405,7 +400,7 @@ private class MutableMetaWithDefault( override val items: Map get() { val sourceKeys: Collection = source[rootName]?.items?.keys ?: emptyList() - val defaultKeys: Collection = default.getMeta(rootName)?.items?.keys ?: emptyList() + val defaultKeys: Collection = default[rootName]?.items?.keys ?: emptyList() //merging keys for primary and default node return (sourceKeys + defaultKeys).associateWith { MutableMetaWithDefault(source, default, rootName + it) @@ -413,12 +408,12 @@ private class MutableMetaWithDefault( } override var value: Value? - get() = source[rootName]?.value ?: default.getMeta(rootName)?.value + get() = source[rootName]?.value ?: default.get(rootName)?.value set(value) { source[rootName] = value } - override fun getMeta(name: Name): MutableMeta = MutableMetaWithDefault(source, default, rootName + name) + override fun get(name: Name): MutableMeta = MutableMetaWithDefault(source, default, rootName + name) override fun toString(): String = Meta.toString(this) override fun equals(other: Any?): Boolean = Meta.equals(this, other as? Meta) diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MutableMetaDelegate.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MutableMetaDelegate.kt index 32d1017a..0f28523c 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MutableMetaDelegate.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MutableMetaDelegate.kt @@ -11,31 +11,31 @@ import kotlin.reflect.KProperty public fun MutableMetaProvider.node(key: Name? = null): ReadWriteProperty = object : ReadWriteProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Meta? { - return getMeta(key ?: property.name.asName()) + return get(key ?: property.name.asName()) } override fun setValue(thisRef: Any?, property: KProperty<*>, value: Meta?) { val name = key ?: property.name.asName() - setMeta(name, value) + set(name, value) } } public fun MutableMetaProvider.node(key: Name? = null, converter: MetaConverter): ReadWriteProperty = object : ReadWriteProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): T? { - return getMeta(key ?: property.name.asName())?.let { converter.metaToObject(it) } + return get(key ?: property.name.asName())?.let { converter.metaToObject(it) } } override fun setValue(thisRef: Any?, property: KProperty<*>, value: T?) { val name = key ?: property.name.asName() - setMeta(name, value?.let { converter.objectToMeta(it) }) + set(name, value?.let { converter.objectToMeta(it) }) } } public fun MutableMetaProvider.value(key: Name? = null): ReadWriteProperty = object : ReadWriteProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Value? = - getMeta(key ?: property.name.asName())?.value + get(key ?: property.name.asName())?.value override fun setValue(thisRef: Any?, property: KProperty<*>, value: Value?) { setValue(key ?: property.name.asName(), value) @@ -48,7 +48,7 @@ public fun MutableMetaProvider.value( reader: (Value?) -> T ): ReadWriteProperty = object : ReadWriteProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): T = - reader(getMeta(key ?: property.name.asName())?.value) + reader(get(key ?: property.name.asName())?.value) override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) { setValue(key ?: property.name.asName(), writer(value)) diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/ObservableMeta.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/ObservableMeta.kt index 835c7e9a..5a2b05f7 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/ObservableMeta.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/ObservableMeta.kt @@ -36,7 +36,7 @@ public interface ObservableMeta : Meta { public interface ObservableMutableMeta : ObservableMeta, MutableMeta, MutableTypedMeta { override fun getOrCreate(name: Name): ObservableMutableMeta - override fun getMeta(name: Name): ObservableMutableMeta? { + override fun get(name: Name): ObservableMutableMeta? { tailrec fun ObservableMutableMeta.find(name: Name): ObservableMutableMeta? = if (name.isEmpty()) { this } else { diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/ObservableMetaWrapper.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/ObservableMetaWrapper.kt index e231fbc5..76645d83 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/ObservableMetaWrapper.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/ObservableMetaWrapper.kt @@ -17,8 +17,8 @@ private class ObservableMetaWrapper( ObservableMetaWrapper(root, absoluteName + it, listeners) } - override fun getMeta(name: Name): ObservableMutableMeta? = - root.getMeta(name)?.let { ObservableMetaWrapper(root, this.absoluteName + name, listeners) } + override fun get(name: Name): ObservableMutableMeta? = + root.get(name)?.let { ObservableMetaWrapper(root, this.absoluteName + name, listeners) } @ThreadSafe override fun onChange(owner: Any?, callback: Meta.(name: Name) -> Unit) { @@ -49,11 +49,11 @@ private class ObservableMetaWrapper( override fun getOrCreate(name: Name): ObservableMutableMeta = ObservableMetaWrapper(root, this.absoluteName + name, listeners) - override fun setMeta(name: Name, node: Meta?) { + override fun set(name: Name, node: Meta?) { val oldMeta = get(name) //don't forget to remove listener oldMeta?.removeListener(this) - root.setMeta(absoluteName + name, node) + root.set(absoluteName + name, node) if (oldMeta != node) { invalidate(name) } @@ -69,7 +69,7 @@ private class ObservableMetaWrapper( override fun attach(name: Name, node: ObservableMutableMeta) { set(name, node) node.onChange(this) { changeName -> - setMeta(name + changeName, this[changeName]) + set(name + changeName, this[changeName]) } } } diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Scheme.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Scheme.kt index 653c8b05..90473286 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Scheme.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Scheme.kt @@ -47,11 +47,11 @@ public open class Scheme : Described, MetaRepr, MutableMetaProvider, Configurabl return descriptor?.validate(meta) ?: true } - override fun getMeta(name: Name): MutableMeta? = meta.getMeta(name) + override fun get(name: Name): MutableMeta? = meta.get(name) - override fun setMeta(name: Name, node: Meta?) { + override fun set(name: Name, node: Meta?) { if (validate(name, meta)) { - meta.setMeta(name, node) + meta.set(name, node) } else { error("Validation failed for node $node at $name") } @@ -110,8 +110,8 @@ public open class Scheme : Described, MetaRepr, MutableMetaProvider, Configurabl override fun equals(other: Any?): Boolean = Meta.equals(this, other as? Meta) override fun hashCode(): Int = Meta.hashCode(this) - override fun setMeta(name: Name, node: Meta?) { - targetMeta.setMeta(name, node) + override fun set(name: Name, node: Meta?) { + targetMeta.set(name, node) invalidate(name) } @@ -120,9 +120,9 @@ public open class Scheme : Described, MetaRepr, MutableMetaProvider, Configurabl @DFExperimental override fun attach(name: Name, node: ObservableMutableMeta) { //TODO implement zero-copy attachment - setMeta(name, node) + set(name, node) node.onChange(this) { changeName -> - setMeta(name + changeName, this[changeName]) + set(name + changeName, this[changeName]) } } diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/SealedMeta.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/SealedMeta.kt index 1efec0f1..217a6a04 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/SealedMeta.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/SealedMeta.kt @@ -62,7 +62,7 @@ internal class MetaBuilder( val existing = get(name) as? MetaBuilder return if (existing == null) { val newItem = MetaBuilder() - setMeta(name, newItem) + set(name, newItem) newItem } else { existing @@ -75,7 +75,7 @@ internal class MetaBuilder( ) - override fun setMeta(name: Name, node: Meta?) { + override fun set(name: Name, node: Meta?) { when (name.length) { 0 -> error("Can't set a meta with empty name") 1 -> { @@ -89,7 +89,7 @@ internal class MetaBuilder( } else -> { - getOrCreate(name.first().asName()).setMeta(name.cutFirst(), node) + getOrCreate(name.first().asName()).set(name.cutFirst(), node) } } } diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/transformations/MetaTransformation.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/transformations/MetaTransformation.kt index be35106b..d41365a6 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/transformations/MetaTransformation.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/transformations/MetaTransformation.kt @@ -42,7 +42,7 @@ public data class KeepTransformationRule(val selector: (Name) -> Boolean) : meta.nodeSequence().map { it.first }.filter(selector) override fun transformItem(name: Name, item: Meta?, target: MutableMeta) { - if (selector(name)) target.setMeta(name, item) + if (selector(name)) target.set(name, item) } } @@ -174,7 +174,7 @@ public class MetaTransformationBuilder { public fun keep(regex: String) { transformations.add( RegexItemTransformationRule(regex.toRegex()) { name, _, Meta -> - setMeta(name, Meta) + set(name, Meta) }) } @@ -184,7 +184,7 @@ public class MetaTransformationBuilder { public fun move(from: Name, to: Name, operation: (Meta?) -> Meta? = { it }) { transformations.add( SingleItemTransformationRule(from) { _, item -> - setMeta(to, operation(item)) + set(to, operation(item)) } ) }