public KeyEvent(String message) { if (message.length() != 2) { throw new IllegalArgumentException(); } this.function = Function.fromProtocol(message.charAt(0)); this.clickType = ClickType.fromProtocol(message.charAt(1)); }
public static ClickType fromProtocol(char c) { for (ClickType clickType : ClickType.values()) { if (clickType.protocolValue == c) { return clickType; } } throw new IllegalArgumentException(); }
@Override public int hashCode() { int result = function != null ? function.hashCode() : 0; result = 31 * result + (clickType != null ? clickType.hashCode() : 0); return result; }