I have an enumeration that in a simplified form looks like this.
public enum Codes{
Code1("someCode1", "someState"),
Code2("someCode2", "someState"),
...
...
private final String m_code;
private final String m_state;
}
My goal - to ensure that when someone else is editing this listing to add a new value, for example Code100, m_codefor Code100should not be the same as m_codefor any of the previous Code1- Code99. The only way I could think of is to write a unit test for this listing, which will do this check. Is there a better solution to this problem?
Ideally, I would like a compile-time error for this situation, but I'm not sure if this can be done in Java?
source
share