From 65a5379f4a3d78da076eb8f61374bf05d8e29389 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 28 May 2019 17:59:55 +0300 Subject: [PATCH] build fix --- .../kotlin/hep/dataforge/descriptors/Described.kt | 3 +++ .../hep/dataforge/descriptors/NodeDescriptor.kt | 12 +++++++----- .../hep/dataforge/descriptors/ValueDescriptor.kt | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/descriptors/Described.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/descriptors/Described.kt index a0780a3e..0ae7a13c 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/descriptors/Described.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/descriptors/Described.kt @@ -1,5 +1,8 @@ package hep.dataforge.descriptors +/** + * An object which provides its descriptor + */ interface Described { val descriptor: NodeDescriptor } \ No newline at end of file diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/descriptors/NodeDescriptor.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/descriptors/NodeDescriptor.kt index 238cc865..df748acf 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/descriptors/NodeDescriptor.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/descriptors/NodeDescriptor.kt @@ -83,12 +83,12 @@ class NodeDescriptor(override val config: Config) : Specific { * The list of value descriptors */ val values: Map - get() = config.getAll("value".toName()).entries.associate { (name, node) -> + get() = config.getAll(VALUE_KEY.toName()).entries.associate { (name, node) -> name to ValueDescriptor.wrap(node.node ?: error("Value descriptor must be a node")) } fun value(name: String, descriptor: ValueDescriptor) { - val token = NameToken("value", name) + val token = NameToken(VALUE_KEY, name) config[token] = descriptor.config } @@ -103,13 +103,13 @@ class NodeDescriptor(override val config: Config) : Specific { * The map of children node descriptors */ val nodes: Map - get() = config.getAll("node".toName()).entries.associate { (name, node) -> + get() = config.getAll(NODE_KEY.toName()).entries.associate { (name, node) -> name to wrap(node.node ?: error("Node descriptor must be a node")) } fun node(name: String, descriptor: NodeDescriptor) { - val token = NameToken("node", name) + val token = NameToken(NODE_KEY, name) config[token] = descriptor.config } @@ -122,7 +122,9 @@ class NodeDescriptor(override val config: Config) : Specific { companion object : Specification { - override fun wrap(config: Config): NodeDescriptor = NodeDescriptor(config) + const val NODE_KEY = "node" + const val VALUE_KEY = "value" + override fun wrap(config: Config): NodeDescriptor = NodeDescriptor(config) } } diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/descriptors/ValueDescriptor.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/descriptors/ValueDescriptor.kt index e3acd07b..cc3352c0 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/descriptors/ValueDescriptor.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/descriptors/ValueDescriptor.kt @@ -126,7 +126,7 @@ class ValueDescriptor(override val config: Config) : Specific { override fun wrap(config: Config): ValueDescriptor = ValueDescriptor(config) inline fun > enum(name: String) = - ValueDescriptor.build { + build { this.name = name type(ValueType.STRING) this.allowedValues = enumValues().map { Value.of(it.name) }