| 1 | // https://stackoverflow.com/questions/28548015/how-do-i-create-an-enum-from-a-string-in-kotlin |
| 2 | inline fun <reified T : Enum<T>> valueOf(type: String): T? { |
| 3 | return try { |
| 4 | java.lang.Enum.valueOf(T::class.java, type) |
| 5 | } catch (e: Exception) { |
| 6 | null |
| 7 | } |
| 8 | } |
rcaldous / Enum from String - Kotlin
Last active 4 months ago
Revision 8f0974614c7fb824301eca38cd8d728abec80ed9