Lets say i have the following object
User {
gender: Gender = MALE
age: Int = 0
}
and i stored this in firestore. now assume the Gender is a enum as follows
enum class Gender {
MALE,
FEMALE
}
if i would now say i want to extend the Gender enum with OTHER and store this in firestore and an earlier version of my app wants to read this from firestore it does not know the gender OTHER. if i would the read form a colleciton and call snapshot.toObject<Gender>() this would lead to an error: java.lang.RuntimeException: Could not deserialize object. Could not find enum value of User for value "OTHER" (found in field 'gender').
How would i say if this happens that i would choose for example MALE by default and the exception would not occur. since i cannot override the valueOf() function of an enum that is used by the toObject() function i have completely no clue how todo this. any suggestions?