Fixed value delegate
This commit is contained in:
parent
459e570437
commit
a56fa74ab6
@ -75,7 +75,7 @@ class ValueDescriptor(override val config: Config) : Specific {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
var type: List<ValueType> by value().map {
|
var type: List<ValueType> by value {
|
||||||
it?.list?.map { v -> ValueType.valueOf(v.string) } ?: emptyList()
|
it?.list?.map { v -> ValueType.valueOf(v.string) } ?: emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ class ValueDescriptor(override val config: Config) : Specific {
|
|||||||
this.type = listOf(*t)
|
this.type = listOf(*t)
|
||||||
}
|
}
|
||||||
|
|
||||||
var tags: List<String> by value().map { value ->
|
var tags: List<String> by value { value ->
|
||||||
value?.list?.map { it.string } ?: emptyList()
|
value?.list?.map { it.string } ?: emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ class ValueDescriptor(override val config: Config) : Specific {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
var allowedValues: List<Value> by value().map {
|
var allowedValues: List<Value> by value {
|
||||||
it?.list ?: if (type.size == 1 && type[0] === ValueType.BOOLEAN) {
|
it?.list ?: if (type.size == 1 && type[0] === ValueType.BOOLEAN) {
|
||||||
listOf(True, False)
|
listOf(True, False)
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package hep.dataforge.meta
|
package hep.dataforge.meta
|
||||||
|
|
||||||
|
import hep.dataforge.values.Null
|
||||||
import hep.dataforge.values.Value
|
import hep.dataforge.values.Value
|
||||||
import kotlin.jvm.JvmName
|
import kotlin.jvm.JvmName
|
||||||
|
|
||||||
@ -9,7 +10,7 @@ import kotlin.jvm.JvmName
|
|||||||
/**
|
/**
|
||||||
* A property delegate that uses custom key
|
* A property delegate that uses custom key
|
||||||
*/
|
*/
|
||||||
fun <T> Configurable.value(default: T, key: String? = null) =
|
fun Configurable.value(default: Any = Null, key: String? = null) =
|
||||||
MutableValueDelegate(config, key, Value.of(default))
|
MutableValueDelegate(config, key, Value.of(default))
|
||||||
|
|
||||||
fun <T> Configurable.value(default: T? = null, key: String? = null, transform: (Value?) -> T) =
|
fun <T> Configurable.value(default: T? = null, key: String? = null, transform: (Value?) -> T) =
|
||||||
|
Loading…
Reference in New Issue
Block a user