enum class Types(val value: Int) { FOO(1), BAR(2), FOO_BAR(3); companion object { fun fromInt(value: Int) = Types.values().first { it.value == value } }}
You may want to add a safety check for the range and return null.
enum class Types(val value: Int) { FOO(1), BAR(2), FOO_BAR(3); companion object { fun fromInt(value: Int) = Types.values().first { it.value == value } }}
You may want to add a safety check for the range and return null.