enum
s in Java are implicitly final
, so you can't inherit them from each other. I'd have the two different enum
s, like you have in the OP, and add a couple of methods to convert between them:
public static SessionState convert(SessionStateCopy s) {
return SessionState.valueOf(s.name());
}
public static SessionStateCopy convert(SessionState s) {
return SessionStateCopy .valueOf(s.name());
}
Just to make sure you don't accidently add a value to one and not the other, I'd add a JUnit test to ensure this:
// imports snipped for clarity
public class SessionStateTest() {
public void testMatchingMembers() {
assertEquals("wrong number of values", SessionState.values().size(), SessionStateCopy.values().size());
for (SessionState s: SessionState.values()) {
assertEquals ("wrong value", s, convert(convert(s));
}
}
}