@Test public void testDoesShortcutConflict() { final KeyShortcut shortcut = new KeyShortcut("some", KeyEvent.VK_0, KeyEvent.SHIFT_MASK); assertFalse(shortcut.doesConflictWith(null)); assertFalse(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_0, KeyEvent.CTRL_MASK))); assertFalse(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_1, KeyEvent.SHIFT_MASK | KeyEvent.CTRL_MASK))); assertFalse(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_0, KeyEvent.CTRL_DOWN_MASK))); assertFalse(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_1, KeyEvent.SHIFT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK))); assertTrue(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_0, KeyEvent.SHIFT_MASK | KeyEvent.CTRL_MASK))); assertTrue(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_0, KeyEvent.SHIFT_MASK))); assertTrue(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_0, KeyEvent.SHIFT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK))); assertTrue(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_0, KeyEvent.SHIFT_DOWN_MASK))); }
public boolean doesConflictWith(@Nullable final KeyStroke stroke) { boolean result = false; if (stroke != null) { result = stroke.getKeyCode() == this.keyCode && (this.modifiers & stroke.getModifiers()) == this.modifiers; } return result; }
KeyShortcut { public boolean doesConflictWith(@Nullable final KeyStroke stroke) { boolean result = false; if (stroke != null) { result = stroke.getKeyCode() == this.keyCode && (this.modifiers & stroke.getModifiers()) == this.modifiers; } return result; } }
KeyShortcut { public boolean doesConflictWith(@Nullable final KeyStroke stroke) { boolean result = false; if (stroke != null) { result = stroke.getKeyCode() == this.keyCode && (this.modifiers & stroke.getModifiers()) == this.modifiers; } return result; } KeyShortcut(@Nonnull final String packed);  KeyShortcut(@Nonnull final String id, final int keyCode, final int modifiers); }
KeyShortcut { public boolean doesConflictWith(@Nullable final KeyStroke stroke) { boolean result = false; if (stroke != null) { result = stroke.getKeyCode() == this.keyCode && (this.modifiers & stroke.getModifiers()) == this.modifiers; } return result; } KeyShortcut(@Nonnull final String packed);  KeyShortcut(@Nonnull final String id, final int keyCode, final int modifiers); boolean isCtrl(); boolean isAlt(); boolean isShift(); boolean isMeta(); int getModifiers(); int getKeyCode(); @Nonnull String getID(); boolean isEvent(@Nonnull final KeyEvent event); boolean isEvent(@Nonnull final KeyEvent event, final int modifiersPlayingRole); @Override int hashCode(); @Override boolean equals(@Nullable final Object object); @Nonnull String packToString(); @Override @Nonnull String toString(); boolean doesConflictWith(@Nullable final KeyStroke stroke); @Nonnull String getKeyCodeName(); }
KeyShortcut { public boolean doesConflictWith(@Nullable final KeyStroke stroke) { boolean result = false; if (stroke != null) { result = stroke.getKeyCode() == this.keyCode && (this.modifiers & stroke.getModifiers()) == this.modifiers; } return result; } KeyShortcut(@Nonnull final String packed);  KeyShortcut(@Nonnull final String id, final int keyCode, final int modifiers); boolean isCtrl(); boolean isAlt(); boolean isShift(); boolean isMeta(); int getModifiers(); int getKeyCode(); @Nonnull String getID(); boolean isEvent(@Nonnull final KeyEvent event); boolean isEvent(@Nonnull final KeyEvent event, final int modifiersPlayingRole); @Override int hashCode(); @Override boolean equals(@Nullable final Object object); @Nonnull String packToString(); @Override @Nonnull String toString(); boolean doesConflictWith(@Nullable final KeyStroke stroke); @Nonnull String getKeyCodeName(); static final int ALL_MODIFIERS_MASK; }