Protect meta aquisition in Scheme
This commit is contained in:
parent
c01bc36d41
commit
e5f422f9ca
@ -4,7 +4,7 @@ plugins {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
group = "space.kscience"
|
group = "space.kscience"
|
||||||
version = "0.5.0-dev-9"
|
version = "0.5.0-dev-10"
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
|
@ -10,17 +10,19 @@ import space.kscience.dataforge.values.Value
|
|||||||
*/
|
*/
|
||||||
public open class Scheme : Described, MetaRepr, MutableMetaProvider, Configurable {
|
public open class Scheme : Described, MetaRepr, MutableMetaProvider, Configurable {
|
||||||
|
|
||||||
final override var meta: ObservableMutableMeta = MutableMeta()
|
private var _meta = MutableMeta()
|
||||||
private set
|
|
||||||
|
|
||||||
final override var descriptor: MetaDescriptor? = null
|
final override val meta: ObservableMutableMeta get() = _meta
|
||||||
internal set
|
|
||||||
|
internal var metaDescriptor: MetaDescriptor? = null
|
||||||
|
|
||||||
|
final override val descriptor: MetaDescriptor? get() = metaDescriptor
|
||||||
|
|
||||||
internal fun wrap(
|
internal fun wrap(
|
||||||
items: MutableMeta,
|
items: MutableMeta,
|
||||||
preserveDefault: Boolean = false
|
preserveDefault: Boolean = false
|
||||||
) {
|
) {
|
||||||
meta = (if (preserveDefault) items.withDefault(meta.seal()) else items).asObservable()
|
_meta = (if (preserveDefault) items.withDefault(meta.seal()) else items).asObservable()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,7 +71,7 @@ public open class SchemeSpec<out T : Scheme>(
|
|||||||
private val builder: () -> T,
|
private val builder: () -> T,
|
||||||
) : Specification<T>, Described {
|
) : Specification<T>, Described {
|
||||||
|
|
||||||
override fun read(source: Meta): T = empty().also {
|
override fun read(source: Meta): T = builder().also {
|
||||||
it.wrap(MutableMeta().withDefault(source))
|
it.wrap(MutableMeta().withDefault(source))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +83,7 @@ public open class SchemeSpec<out T : Scheme>(
|
|||||||
override val descriptor: MetaDescriptor? get() = null
|
override val descriptor: MetaDescriptor? get() = null
|
||||||
|
|
||||||
override fun empty(): T = builder().also {
|
override fun empty(): T = builder().also {
|
||||||
it.descriptor = descriptor
|
it.metaDescriptor = descriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("OVERRIDE_BY_INLINE")
|
@Suppress("OVERRIDE_BY_INLINE")
|
||||||
|
Loading…
Reference in New Issue
Block a user