Minor updates for mutable meta and builder
This commit is contained in:
parent
9f6d53f214
commit
c82eda28d8
@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("scientifik.mpp") version "0.1.4-dev" apply false
|
id("scientifik.mpp") version "0.1.4" apply false
|
||||||
id("scientifik.publish") version "0.1.4-dev" apply false
|
id("scientifik.publish") version "0.1.4" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
val dataforgeVersion by extra("0.1.3-dev-10")
|
val dataforgeVersion by extra("0.1.3-dev-10")
|
||||||
|
@ -7,6 +7,11 @@ import hep.dataforge.names.plus
|
|||||||
|
|
||||||
//TODO add validator to configuration
|
//TODO add validator to configuration
|
||||||
|
|
||||||
|
data class MetaListener(
|
||||||
|
val owner: Any? = null,
|
||||||
|
val action: (name: Name, oldItem: MetaItem<*>?, newItem: MetaItem<*>?) -> Unit
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutable meta representing object state
|
* Mutable meta representing object state
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package hep.dataforge.meta
|
package hep.dataforge.meta
|
||||||
|
|
||||||
|
import hep.dataforge.names.Name
|
||||||
import hep.dataforge.names.asName
|
import hep.dataforge.names.asName
|
||||||
import hep.dataforge.values.Value
|
import hep.dataforge.values.Value
|
||||||
|
|
||||||
@ -28,6 +29,25 @@ class MetaBuilder : AbstractMutableMeta<MetaBuilder>() {
|
|||||||
infix fun String.to(metaBuilder: MetaBuilder.() -> Unit) {
|
infix fun String.to(metaBuilder: MetaBuilder.() -> Unit) {
|
||||||
this@MetaBuilder[this] = MetaBuilder().apply(metaBuilder)
|
this@MetaBuilder[this] = MetaBuilder().apply(metaBuilder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
infix fun Name.to(value: Any) {
|
||||||
|
if (value is Meta) {
|
||||||
|
this@MetaBuilder[this] = value
|
||||||
|
}
|
||||||
|
this@MetaBuilder[this] = Value.of(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
infix fun Name.to(meta: Meta) {
|
||||||
|
this@MetaBuilder[this] = meta
|
||||||
|
}
|
||||||
|
|
||||||
|
infix fun Name.to(value: Iterable<Meta>) {
|
||||||
|
this@MetaBuilder[this] = value.toList()
|
||||||
|
}
|
||||||
|
|
||||||
|
infix fun Name.to(metaBuilder: MetaBuilder.() -> Unit) {
|
||||||
|
this@MetaBuilder[this] = MetaBuilder().apply(metaBuilder)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,12 +3,6 @@ package hep.dataforge.meta
|
|||||||
import hep.dataforge.names.*
|
import hep.dataforge.names.*
|
||||||
import hep.dataforge.values.Value
|
import hep.dataforge.values.Value
|
||||||
|
|
||||||
internal data class MetaListener(
|
|
||||||
val owner: Any? = null,
|
|
||||||
val action: (name: Name, oldItem: MetaItem<*>?, newItem: MetaItem<*>?) -> Unit
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
interface MutableMeta<M : MutableMeta<M>> : MetaNode<M> {
|
interface MutableMeta<M : MutableMeta<M>> : MetaNode<M> {
|
||||||
override val items: Map<NameToken, MetaItem<M>>
|
override val items: Map<NameToken, MetaItem<M>>
|
||||||
operator fun set(name: Name, item: MetaItem<*>?)
|
operator fun set(name: Name, item: MetaItem<*>?)
|
||||||
|
Loading…
Reference in New Issue
Block a user