build fix

This commit is contained in:
Alexander Nozik 2019-05-28 17:59:55 +03:00
parent 13c5a579ed
commit 65a5379f4a
3 changed files with 11 additions and 6 deletions

View File

@ -1,5 +1,8 @@
package hep.dataforge.descriptors package hep.dataforge.descriptors
/**
* An object which provides its descriptor
*/
interface Described { interface Described {
val descriptor: NodeDescriptor val descriptor: NodeDescriptor
} }

View File

@ -83,12 +83,12 @@ class NodeDescriptor(override val config: Config) : Specific {
* The list of value descriptors * The list of value descriptors
*/ */
val values: Map<String, ValueDescriptor> val values: Map<String, ValueDescriptor>
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")) name to ValueDescriptor.wrap(node.node ?: error("Value descriptor must be a node"))
} }
fun value(name: String, descriptor: ValueDescriptor) { fun value(name: String, descriptor: ValueDescriptor) {
val token = NameToken("value", name) val token = NameToken(VALUE_KEY, name)
config[token] = descriptor.config config[token] = descriptor.config
} }
@ -103,13 +103,13 @@ class NodeDescriptor(override val config: Config) : Specific {
* The map of children node descriptors * The map of children node descriptors
*/ */
val nodes: Map<String, NodeDescriptor> val nodes: Map<String, NodeDescriptor>
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")) name to wrap(node.node ?: error("Node descriptor must be a node"))
} }
fun node(name: String, descriptor: NodeDescriptor) { fun node(name: String, descriptor: NodeDescriptor) {
val token = NameToken("node", name) val token = NameToken(NODE_KEY, name)
config[token] = descriptor.config config[token] = descriptor.config
} }
@ -122,7 +122,9 @@ class NodeDescriptor(override val config: Config) : Specific {
companion object : Specification<NodeDescriptor> { companion object : Specification<NodeDescriptor> {
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)
} }
} }

View File

@ -126,7 +126,7 @@ class ValueDescriptor(override val config: Config) : Specific {
override fun wrap(config: Config): ValueDescriptor = ValueDescriptor(config) override fun wrap(config: Config): ValueDescriptor = ValueDescriptor(config)
inline fun <reified E : Enum<E>> enum(name: String) = inline fun <reified E : Enum<E>> enum(name: String) =
ValueDescriptor.build { build {
this.name = name this.name = name
type(ValueType.STRING) type(ValueType.STRING)
this.allowedValues = enumValues<E>().map { Value.of(it.name) } this.allowedValues = enumValues<E>().map { Value.of(it.name) }