Is it possible to have one enumeration constant extend another one (from the same enumeration)?
Pseudo-code:
private enum Mode{
FRIGHTENED, BLINKING extends FRIGHTENED, SCATTER
}
This way, one could use the enum-constants in a switch-block like this:
switch (some_mode){
case FRIGHTENED:
// This would trigger when the actual "some_mode" is set
// to FRIGHTENED or BLINKING
break;
case BLINKING:
// This would only trigger if the actual "some_mode" is set to BLINKING
}
Is there any pattern which would allow me to do this, or am I just completely out of my mind?
I might have to be a little more clear about the shown use-case in a switch-statement: I plan to not check for all possible values, but only for the “parent” one.
if (some_mode == Mode.FRIGHTENED){
// The behavior in FRIGHTENED and BLINKING mode is the same. The only
// difference is the way they are visualized.
}
There’s a tortured way to simulated this, but no, it’s not possible for one enumeration constant to extend another.