I'll make it short and quick. I have an enum that represents "commands", the commands are sent of the net so they're translate from chars to bytes -
public static enum Command {
EXIT('E'),
PLAY('P'),
OK('O'),
ROTATE('R'),
FORWARD('W'),
BACKWARD('S'),
LIFT('L'),
TURRET('T'),
FIRE('F');
private final byte command;
private Command(char command) {
this.command = ((byte) (command & 0xFF));
}
public byte asByte() {
return command;
}
public char asChar() {
return (char) command;
}
}
But, for some reason I'm getting the following error while trying to "switch" them -
constant expression required
Here is the switch statement:
public void readData(byte[] data) {
switch (data[0]) {
case Command.PLAY.asByte():
sendCommand(new byte[]{Command.OK.asByte(), 0});
break;
}
}
The switch isn't complete due to the error.
Any help would be welcomed.