I have some enums like this:
public enum Classification { UNKNOWN("Unknown"), DELETION("Deletion"), DUPLICATION("Duplication"), .... but some of them have like 20 members, so currently in code I deal with them with huge if/else blocks like this:
int classification= rs.getInt("classification"); if (classification == Classification.UNKNOWN.ordinal()) { variant.setClassification(Classification.UNKNOWN); } else if (classification == Classification.DELETION.ordinal()) { variant.setClassification(Classification.DELETION); ( rs is from JDBC tho).
Does Java have a better way this these big if/else blocks to do what I am doing? some sorting of looping through it?