Is there a better (or "more Kotlin") way to get an...
# codereview
h
Is there a better (or "more Kotlin") way to get an enum value when I don't have a concrete type? It feels weird having to resort to
java.lang.Enum
...
Copy code
sealed class EnumBinding<E : Enum<E>>(
	private val enumType: Class<E>
) : Binding<Any?, E?> {

	override fun converter(): Converter<Any?, E?> = object : Converter<Any?, E?> {
		override fun from(databaseObject: Any?): E? =
			databaseObject?.let { java.lang.Enum.valueOf(enumType, it.toString()) }
        …
    }
    …
}
(it's a custom jOOQ binding, so I can't change
Binding
or
Converter
)
tl;dr ideally there would be, and there's a feature request, but for now there's no way to it without Java reflection
h
Thank you! Upvoted. (but 5 years already … 😟)
m
h
no, because you can't write a concrete type for
T
m
I see, thanks