Fixed enum delegate
This commit is contained in:
parent
3ff3a5d09e
commit
156a43d4bf
@ -242,7 +242,7 @@ val MetaItem<*>?.long get() = number?.toLong()
|
||||
val MetaItem<*>?.short get() = number?.toShort()
|
||||
|
||||
inline fun <reified E : Enum<E>> MetaItem<*>?.enum() = if (this is ValueItem && this.value is EnumValue<*>) {
|
||||
this.value as E
|
||||
this.value.value as E
|
||||
} else {
|
||||
string?.let { enumValueOf<E>(it) }
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package hep.dataforge.meta
|
||||
|
||||
import org.junit.Test
|
||||
import kotlin.test.Test
|
||||
|
||||
|
||||
class MetaExtensionTest {
|
||||
|
||||
@ -15,7 +16,7 @@ class MetaExtensionTest {
|
||||
}
|
||||
@Test
|
||||
fun testEnumByString(){
|
||||
val meta = buildMeta{"enum" to TestEnum.test.toString()}
|
||||
val meta = buildMeta{"enum" to TestEnum.test.name}
|
||||
println(meta["enum"].enum<TestEnum>())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user