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 38b509e7..e3acd07b 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/descriptors/ValueDescriptor.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/descriptors/ValueDescriptor.kt @@ -75,7 +75,7 @@ class ValueDescriptor(override val config: Config) : Specific { * * @return */ - var type: List by value().map { + var type: List by value { it?.list?.map { v -> ValueType.valueOf(v.string) } ?: emptyList() } @@ -83,7 +83,7 @@ class ValueDescriptor(override val config: Config) : Specific { this.type = listOf(*t) } - var tags: List by value().map { value -> + var tags: List by value { value -> value?.list?.map { it.string } ?: emptyList() } @@ -106,7 +106,7 @@ class ValueDescriptor(override val config: Config) : Specific { * * @return */ - var allowedValues: List by value().map { + var allowedValues: List by value { it?.list ?: if (type.size == 1 && type[0] === ValueType.BOOLEAN) { listOf(True, False) } else { diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/ConfigDelegates.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/ConfigDelegates.kt index 9baa802a..8b439a98 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/ConfigDelegates.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/ConfigDelegates.kt @@ -1,5 +1,6 @@ package hep.dataforge.meta +import hep.dataforge.values.Null import hep.dataforge.values.Value import kotlin.jvm.JvmName @@ -9,7 +10,7 @@ import kotlin.jvm.JvmName /** * A property delegate that uses custom key */ -fun Configurable.value(default: T, key: String? = null) = +fun Configurable.value(default: Any = Null, key: String? = null) = MutableValueDelegate(config, key, Value.of(default)) fun Configurable.value(default: T? = null, key: String? = null, transform: (Value?) -> T) =