ShortcutRegistration implements Registration, Serializable { public ShortcutRegistration listenOn(Component... listenOnComponents) { Objects.requireNonNull(listenOnComponents, "listenOnComponents must not be null!"); if (Arrays.stream(listenOnComponents).anyMatch(Objects::isNull)) { throw new IllegalArgumentException( LISTEN_ON_COMPONENTS_SHOULD_NOT_CONTAIN_NULL); } if (hasDuplicate(listenOnComponents)) { throw new IllegalArgumentException( LISTEN_ON_COMPONENTS_SHOULD_NOT_HAVE_DUPLICATE_ENTRIES); } removeAllListenerRegistrations(); final Component[] copyOfListenOnComponents = Arrays .copyOf(listenOnComponents, listenOnComponents.length); this.listenOnSuppliers = () -> copyOfListenOnComponents; prepareForClientResponse(); return this; } ShortcutRegistration(Component lifecycleOwner,
            SerializableSupplier<Component[]> listenOnSuppliers,
            ShortcutEventListener eventListener, Key key); ShortcutRegistration withModifiers(KeyModifier... keyModifiers); ShortcutRegistration withAlt(); ShortcutRegistration withCtrl(); ShortcutRegistration withMeta(); ShortcutRegistration withShift(); ShortcutRegistration allowBrowserDefault(); ShortcutRegistration allowEventPropagation(); ShortcutRegistration bindLifecycleTo(Component component); ShortcutRegistration listenOn(Component... listenOnComponents); @Override void remove(); boolean isShortcutActive(); Key getKey(); Set<Key> getModifiers(); boolean isBrowserDefaultAllowed(); void setBrowserDefaultAllowed(boolean browserDefaultAllowed); boolean isEventPropagationAllowed(); void setEventPropagationAllowed(boolean eventPropagationAllowed); @Deprecated Component getOwner(); Component[] getOwners(); Component getLifecycleOwner(); @Override String toString();  }
@Test public void listenOnWithDuplicateShouldThrowException() { ShortcutRegistration registration = new ShortcutRegistration( lifecycleOwner, () -> listenOn, event -> { }, Key.KEY_A); exceptionRule.expect(IllegalArgumentException.class); exceptionRule.expectMessage( ShortcutRegistration.LISTEN_ON_COMPONENTS_SHOULD_NOT_HAVE_DUPLICATE_ENTRIES); registration.listenOn(listenOn[0], listenOn[1], listenOn[1]); }
@Test public void listenOnWithNullEntriesShouldThrowException() { ShortcutRegistration registration = new ShortcutRegistration( lifecycleOwner, () -> listenOn, event -> { }, Key.KEY_A); exceptionRule.expect(IllegalArgumentException.class); exceptionRule.expectMessage( ShortcutRegistration.LISTEN_ON_COMPONENTS_SHOULD_NOT_CONTAIN_NULL); registration.listenOn(listenOn[0], null, listenOn[1]); }