Class Registrations
Registration pairs.
Replaces the per-family *Support holders (see
SD_vaadin_first_binding: Vaadin-first direct-binding stance).
Each addXListener on a mixin creates the matching Vaadin
subscription (on FocusNotifier etc.),
calls add(EventListener, Registration) with the Swing listener
as the key and the Vaadin Registration as the value, and
returns. removeXListener looks up the Swing listener, calls
Registration.remove(), and drops the entry. getXListeners()
filters the keys by type — LinkedHashMap preserves insertion
order, which matches Swing's listener-array order.
One Registrations per component; concurrent multi-threaded
access isn't modelled (Vaadin's session lock serialises UI-thread
access, which is where these operations happen).
Adding the same listener instance twice collapses to a single entry
— the second add(EventListener, Registration) replaces the first registration and removes
the stale one. Swing's contract does let the same listener register
twice and fire twice; the current pattern treats that as a programming
error we'd rather squash than replicate, and it keeps the map semantics
clean. Revisit if a migration target relies on double-fire.
-
Method Summary
Modifier and TypeMethodDescriptionvoidadd(EventListener listener, com.vaadin.flow.shared.Registration registration) Registerlistenerwith the Vaadin-sideregistration.<T extends EventListener>
T[]getListeners(Class<T> type) Return all listeners of typetypein registration order.static Registrationsof(com.vaadin.flow.component.Component target) voidremove(EventListener listener) Remove andRegistration.remove()the Vaadin registration forlistener.intsize()Test/diagnostic accessor — total registration count.
-
Method Details
-
of
-
remove
Remove andRegistration.remove()the Vaadin registration forlistener. No-op when the listener wasn't registered. -
getListeners
Return all listeners of typetypein registration order. Used bygetXListeners()accessors on the mixins —getFocusListeners()passesFocusListener.class,getHierarchyListeners()passesHierarchyListener.class, and so on. -
size
public int size()Test/diagnostic accessor — total registration count.
-