iex
01/10/2020, 1:24 PMenum class MyEnum {
@SerializedName("my_foo") FOO // "my_foo" -> FOO (for deserialization)
...
}
MyEnum.FOO.string // FOO -> "my_foo"
iex
01/10/2020, 1:36 PMcompanion object {
private val map = Type.values().associateBy(Type::value)
fun fromInt(type: Int) = map[type]
}
is actually enough. I'll not deserialize it with directly gson but just create a lazy field that converts the string to an enum.