From 1284aa9f2e69116e867f0e26159303a22e6362cf Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 11 Nov 2020 13:37:02 +0300 Subject: [PATCH] Configurable is no longer MutableItemProvider. All functionality moved to Scheme --- dataforge-meta/api/dataforge-meta.api | 21 ++++++------------- .../kotlin/hep/dataforge/meta/Configurable.kt | 14 +------------ .../hep/dataforge/meta/MutableItemDelegate.kt | 4 ---- .../kotlin/hep/dataforge/meta/Scheme.kt | 6 +++--- 4 files changed, 10 insertions(+), 35 deletions(-) diff --git a/dataforge-meta/api/dataforge-meta.api b/dataforge-meta/api/dataforge-meta.api index f946f881..031cb33d 100644 --- a/dataforge-meta/api/dataforge-meta.api +++ b/dataforge-meta/api/dataforge-meta.api @@ -38,15 +38,8 @@ public final class hep/dataforge/meta/ConfigKt { public static final fun get (Lhep/dataforge/meta/Config;Lhep/dataforge/names/NameToken;)Lhep/dataforge/meta/MetaItem; } -public abstract interface class hep/dataforge/meta/Configurable : hep/dataforge/meta/MutableItemProvider { +public abstract interface class hep/dataforge/meta/Configurable { public abstract fun getConfig ()Lhep/dataforge/meta/Config; - public abstract fun getItem (Lhep/dataforge/names/Name;)Lhep/dataforge/meta/MetaItem; - public abstract fun setItem (Lhep/dataforge/names/Name;Lhep/dataforge/meta/MetaItem;)V -} - -public final class hep/dataforge/meta/Configurable$DefaultImpls { - public static fun getItem (Lhep/dataforge/meta/Configurable;Lhep/dataforge/names/Name;)Lhep/dataforge/meta/MetaItem; - public static fun setItem (Lhep/dataforge/meta/Configurable;Lhep/dataforge/names/Name;Lhep/dataforge/meta/MetaItem;)V } public final class hep/dataforge/meta/ConfigurableKt { @@ -414,10 +407,8 @@ public final class hep/dataforge/meta/MutableItemDelegateKt { public static final fun stringList (Lhep/dataforge/meta/MutableItemProvider;[Ljava/lang/String;Lhep/dataforge/names/Name;)Lkotlin/properties/ReadWriteProperty; public static synthetic fun stringList$default (Lhep/dataforge/meta/MutableItemProvider;Lhep/dataforge/names/Name;ILjava/lang/Object;)Lkotlin/properties/ReadWriteProperty; public static synthetic fun stringList$default (Lhep/dataforge/meta/MutableItemProvider;[Ljava/lang/String;Lhep/dataforge/names/Name;ILjava/lang/Object;)Lkotlin/properties/ReadWriteProperty; - public static final fun value (Lhep/dataforge/meta/Configurable;Lhep/dataforge/names/Name;)Lkotlin/properties/ReadWriteProperty; public static final fun value (Lhep/dataforge/meta/MutableItemProvider;Lhep/dataforge/names/Name;)Lkotlin/properties/ReadWriteProperty; public static final fun value (Lhep/dataforge/meta/MutableItemProvider;Lhep/dataforge/names/Name;Lkotlin/jvm/functions/Function0;)Lkotlin/properties/ReadWriteProperty; - public static synthetic fun value$default (Lhep/dataforge/meta/Configurable;Lhep/dataforge/names/Name;ILjava/lang/Object;)Lkotlin/properties/ReadWriteProperty; public static synthetic fun value$default (Lhep/dataforge/meta/MutableItemProvider;Lhep/dataforge/names/Name;ILjava/lang/Object;)Lkotlin/properties/ReadWriteProperty; public static synthetic fun value$default (Lhep/dataforge/meta/MutableItemProvider;Lhep/dataforge/names/Name;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)Lkotlin/properties/ReadWriteProperty; } @@ -475,15 +466,15 @@ public final class hep/dataforge/meta/ObservableMeta$DefaultImpls { public static fun toMeta (Lhep/dataforge/meta/ObservableMeta;)Lhep/dataforge/meta/Meta; } -public class hep/dataforge/meta/Scheme : hep/dataforge/meta/Configurable, hep/dataforge/meta/MetaRepr, hep/dataforge/meta/descriptors/Described { +public class hep/dataforge/meta/Scheme : hep/dataforge/meta/Configurable, hep/dataforge/meta/MetaRepr, hep/dataforge/meta/MutableItemProvider, hep/dataforge/meta/descriptors/Described { public fun ()V public fun (Lhep/dataforge/meta/Config;Lhep/dataforge/meta/ItemProvider;Lhep/dataforge/meta/descriptors/NodeDescriptor;)V public synthetic fun (Lhep/dataforge/meta/Config;Lhep/dataforge/meta/ItemProvider;Lhep/dataforge/meta/descriptors/NodeDescriptor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getConfig ()Lhep/dataforge/meta/Config; + public fun getConfig ()Lhep/dataforge/meta/Config; public final fun getDefaultItem (Lhep/dataforge/names/Name;)Lhep/dataforge/meta/MetaItem; public fun getDefaultLayer ()Lhep/dataforge/meta/Meta; public synthetic fun getDescriptor ()Lhep/dataforge/meta/descriptors/ItemDescriptor; - public final fun getDescriptor ()Lhep/dataforge/meta/descriptors/NodeDescriptor; + public fun getDescriptor ()Lhep/dataforge/meta/descriptors/NodeDescriptor; public fun getItem (Lhep/dataforge/names/Name;)Lhep/dataforge/meta/MetaItem; public final fun isEmpty ()Z public fun setItem (Lhep/dataforge/names/Name;Lhep/dataforge/meta/MetaItem;)V @@ -495,8 +486,8 @@ public class hep/dataforge/meta/Scheme : hep/dataforge/meta/Configurable, hep/da public final class hep/dataforge/meta/SchemeKt { public static final fun asScheme (Lhep/dataforge/meta/Meta;)Lhep/dataforge/meta/Scheme; public static final fun invoke (Lhep/dataforge/meta/Scheme;Lkotlin/jvm/functions/Function1;)Lhep/dataforge/meta/Scheme; - public static final fun toScheme (Lhep/dataforge/meta/Meta;Lhep/dataforge/meta/Specification;Lkotlin/jvm/functions/Function1;)Lhep/dataforge/meta/Configurable; - public static synthetic fun toScheme$default (Lhep/dataforge/meta/Meta;Lhep/dataforge/meta/Specification;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lhep/dataforge/meta/Configurable; + public static final fun toScheme (Lhep/dataforge/meta/Meta;Lhep/dataforge/meta/Specification;Lkotlin/jvm/functions/Function1;)Lhep/dataforge/meta/MutableItemProvider; + public static synthetic fun toScheme$default (Lhep/dataforge/meta/Meta;Lhep/dataforge/meta/Specification;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lhep/dataforge/meta/MutableItemProvider; } public class hep/dataforge/meta/SchemeSpec : hep/dataforge/meta/Specification, hep/dataforge/meta/descriptors/Described { diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Configurable.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Configurable.kt index 2308bef2..764ee1ea 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Configurable.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Configurable.kt @@ -6,23 +6,11 @@ import kotlin.properties.ReadWriteProperty /** * A container that holds a [Config]. */ -public interface Configurable : MutableItemProvider { +public interface Configurable { /** * Backing config */ public val config: Config - - /** - * Get a property with default - */ - override fun getItem(name: Name): MetaItem<*>? = config[name] - - /** - * Set a configurable property - */ - override fun setItem(name: Name, item: MetaItem<*>?) { - config.setItem(name, item) - } } diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MutableItemDelegate.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MutableItemDelegate.kt index 4d33bea7..e7fb8446 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MutableItemDelegate.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MutableItemDelegate.kt @@ -118,10 +118,6 @@ public inline fun > MutableItemProvider.enum( public inline fun > M.node(key: Name? = null): ReadWriteProperty = item(key).convert(reader = { it?.let { it.node as M } }, writer = { it?.let { MetaItem.NodeItem(it) } }) - -public fun Configurable.value(key: Name? = null): ReadWriteProperty = - item(key).convert(MetaConverter.value) - /* Number delegates */ public fun MutableItemProvider.int(key: Name? = null): ReadWriteProperty = diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Scheme.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Scheme.kt index 7d982404..b9e777e7 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Scheme.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Scheme.kt @@ -13,7 +13,7 @@ public open class Scheme( config: Config = Config(), internal var default: ItemProvider? = null, descriptor: NodeDescriptor? = null, -) : Configurable, Described, MetaRepr { +) : Configurable, MutableItemProvider, Described, MetaRepr { override var config: Config = config internal set @@ -44,7 +44,7 @@ public open class Scheme( */ override fun setItem(name: Name, item: MetaItem<*>?) { if (validateItem(name, item)) { - super.setItem(name, item) + config.setItem(name, item) } else { error("Validation failed for property $name with value $item") } @@ -120,5 +120,5 @@ public open class SchemeSpec( public fun Meta.asScheme(): Scheme = Scheme(this.asConfig(), null, null) -public fun Meta.toScheme(spec: Specification, block: T.() -> Unit = {}): T = +public fun Meta.toScheme(spec: Specification, block: T.() -> Unit = {}): T = spec.wrap(this).apply(block)