Config API change

This commit is contained in:
Alexander Nozik 2020-12-19 20:54:55 +03:00
parent 95e6925d55
commit 1f773cc230
5 changed files with 25 additions and 30 deletions

View File

@ -2,7 +2,7 @@ plugins {
id("ru.mipt.npm.project")
}
val dataforgeVersion by extra("0.2.1-dev-4")
val dataforgeVersion by extra("0.2.1-dev-5")
val bintrayRepo by extra("dataforge")
val githubProject by extra("dataforge-core")

View File

@ -14,7 +14,7 @@ public abstract class hep/dataforge/meta/AbstractMutableMeta : hep/dataforge/met
protected abstract fun wrapNode (Lhep/dataforge/meta/Meta;)Lhep/dataforge/meta/MutableMeta;
}
public final class hep/dataforge/meta/Config : hep/dataforge/meta/AbstractMutableMeta, hep/dataforge/meta/ObservableMeta {
public final class hep/dataforge/meta/Config : hep/dataforge/meta/AbstractMutableMeta, hep/dataforge/meta/ObservableItemProvider {
public static final field ConfigSerializer Lhep/dataforge/meta/Config$ConfigSerializer;
public fun <init> ()V
public synthetic fun empty$dataforge_meta ()Lhep/dataforge/meta/MutableMeta;
@ -108,6 +108,20 @@ public final class hep/dataforge/meta/ItemDelegateKt {
public static synthetic fun value$default (Lhep/dataforge/meta/ItemProvider;Lhep/dataforge/names/Name;ILjava/lang/Object;)Lkotlin/properties/ReadOnlyProperty;
}
public final class hep/dataforge/meta/ItemListener {
public fun <init> (Ljava/lang/Object;Lkotlin/jvm/functions/Function3;)V
public synthetic fun <init> (Ljava/lang/Object;Lkotlin/jvm/functions/Function3;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ljava/lang/Object;
public final fun component2 ()Lkotlin/jvm/functions/Function3;
public final fun copy (Ljava/lang/Object;Lkotlin/jvm/functions/Function3;)Lhep/dataforge/meta/ItemListener;
public static synthetic fun copy$default (Lhep/dataforge/meta/ItemListener;Ljava/lang/Object;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lhep/dataforge/meta/ItemListener;
public fun equals (Ljava/lang/Object;)Z
public final fun getAction ()Lkotlin/jvm/functions/Function3;
public final fun getOwner ()Ljava/lang/Object;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
public abstract interface class hep/dataforge/meta/ItemProvider {
public static final field Companion Lhep/dataforge/meta/ItemProvider$Companion;
public abstract fun getItem (Lhep/dataforge/names/Name;)Lhep/dataforge/meta/MetaItem;
@ -309,20 +323,6 @@ public final class hep/dataforge/meta/MetaKt {
public static final fun values (Lhep/dataforge/meta/Meta;)Lkotlin/sequences/Sequence;
}
public final class hep/dataforge/meta/MetaListener {
public fun <init> (Ljava/lang/Object;Lkotlin/jvm/functions/Function3;)V
public synthetic fun <init> (Ljava/lang/Object;Lkotlin/jvm/functions/Function3;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ljava/lang/Object;
public final fun component2 ()Lkotlin/jvm/functions/Function3;
public final fun copy (Ljava/lang/Object;Lkotlin/jvm/functions/Function3;)Lhep/dataforge/meta/MetaListener;
public static synthetic fun copy$default (Lhep/dataforge/meta/MetaListener;Ljava/lang/Object;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lhep/dataforge/meta/MetaListener;
public fun equals (Ljava/lang/Object;)Z
public final fun getAction ()Lkotlin/jvm/functions/Function3;
public final fun getOwner ()Ljava/lang/Object;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
public abstract interface class hep/dataforge/meta/MetaNode : hep/dataforge/meta/Meta {
public abstract fun getItems ()Ljava/util/Map;
}
@ -456,16 +456,11 @@ public final class hep/dataforge/meta/MutableMetaKt {
public static final fun update (Lhep/dataforge/meta/MutableMeta;Lhep/dataforge/meta/Meta;)V
}
public abstract interface class hep/dataforge/meta/ObservableMeta : hep/dataforge/meta/Meta {
public abstract interface class hep/dataforge/meta/ObservableItemProvider : hep/dataforge/meta/ItemProvider {
public abstract fun onChange (Ljava/lang/Object;Lkotlin/jvm/functions/Function3;)V
public abstract fun removeListener (Ljava/lang/Object;)V
}
public final class hep/dataforge/meta/ObservableMeta$DefaultImpls {
public static fun getItem (Lhep/dataforge/meta/ObservableMeta;Lhep/dataforge/names/Name;)Lhep/dataforge/meta/MetaItem;
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/MutableItemProvider, hep/dataforge/meta/descriptors/Described {
public fun <init> ()V
public fun <init> (Lhep/dataforge/meta/Config;Lhep/dataforge/meta/ItemProvider;Lhep/dataforge/meta/descriptors/NodeDescriptor;)V
@ -671,7 +666,7 @@ public final class hep/dataforge/meta/transformations/MetaTransformation {
public fun equals (Ljava/lang/Object;)Z
public static fun equals-impl (Ljava/util/Collection;Ljava/lang/Object;)Z
public static final fun equals-impl0 (Ljava/util/Collection;Ljava/util/Collection;)Z
public static final fun generate-impl (Ljava/util/Collection;Lhep/dataforge/meta/Config;)Lhep/dataforge/meta/ObservableMeta;
public static final fun generate-impl (Ljava/util/Collection;Lhep/dataforge/meta/Config;)Lhep/dataforge/meta/ObservableItemProvider;
public static final fun generate-impl (Ljava/util/Collection;Lhep/dataforge/meta/Meta;)Lhep/dataforge/meta/Meta;
public final fun getTransformations ()Ljava/util/Collection;
public fun hashCode ()I

View File

@ -14,12 +14,12 @@ import kotlin.jvm.Synchronized
//TODO add validator to configuration
public data class MetaListener(
public data class ItemListener(
val owner: Any? = null,
val action: (name: Name, oldItem: MetaItem<*>?, newItem: MetaItem<*>?) -> Unit
)
public interface ObservableMeta : Meta {
public interface ObservableItemProvider : ItemProvider {
public fun onChange(owner: Any?, action: (name: Name, oldItem: MetaItem<*>?, newItem: MetaItem<*>?) -> Unit)
public fun removeListener(owner: Any?)
}
@ -28,9 +28,9 @@ public interface ObservableMeta : Meta {
* Mutable meta representing object state
*/
@Serializable(Config.Companion::class)
public class Config() : AbstractMutableMeta<Config>(), ObservableMeta {
public class Config() : AbstractMutableMeta<Config>(), ObservableItemProvider {
private val listeners = HashSet<MetaListener>()
private val listeners = HashSet<ItemListener>()
@Synchronized
private fun itemChanged(name: Name, oldItem: MetaItem<*>?, newItem: MetaItem<*>?) {
@ -42,7 +42,7 @@ public class Config() : AbstractMutableMeta<Config>(), ObservableMeta {
*/
@Synchronized
override fun onChange(owner: Any?, action: (Name, MetaItem<*>?, MetaItem<*>?) -> Unit) {
listeners.add(MetaListener(owner, action))
listeners.add(ItemListener(owner, action))
}
/**

View File

@ -46,7 +46,7 @@ public sealed class ItemDescriptor(public val config: Config) {
/**
* Configure attributes of the descriptor, creating an attributes node if needed.
*/
public fun ItemDescriptor.attributes(block: Config.() -> Unit) {
public inline fun ItemDescriptor.attributes(block: Config.() -> Unit) {
(attributes ?: Config().also { this.attributes = it }).apply(block)
}

View File

@ -102,7 +102,7 @@ public inline class MetaTransformation(public val transformations: Collection<Tr
* Generate an observable configuration that contains only elements defined by transformation rules and changes with the source
*/
@DFExperimental
public fun generate(source: Config): ObservableMeta = Config().apply {
public fun generate(source: Config): ObservableItemProvider = Config().apply {
transformations.forEach { rule ->
rule.selectItems(source).forEach { name ->
rule.transformItem(name, source[name], this)