Package com.vaadin.flow.component
Class ComponentEventBusUtil
java.lang.Object
com.vaadin.flow.component.ComponentEventBusUtil
Static helpers and caching functionality for
ComponentEventBus.- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends ComponentEvent<?>>
Constructor<T> getEventConstructor(Class<T> eventType) Gets the constructor to use for firing a component event, of the given type, based on a DOM event.static LinkedHashMap<String, Class<?>> getEventDataExpressions(Class<? extends ComponentEvent<?>> eventType) Gets a map of event data expression (forDomListenerRegistration.addEventData(String)) to Java type, with the same order as the parameters for the event constructor (as returned bygetEventConstructor(Class)).getListenerEventData(Class<? extends ComponentEvent<?>> eventType) Gets the event data expressions to add to a DOM listener registration for the given event type, with expressions for components and elements mapped likeDomListenerRegistration.addEventDataElement(String)does.static booleanisDomEventConstructor(Constructor<?> constructor) Checks if the given constructor can be used when firing aComponentEventbased on aDomEvent.
-
Method Details
-
getEventDataExpressions
public static LinkedHashMap<String,Class<?>> getEventDataExpressions(Class<? extends ComponentEvent<?>> eventType) Gets a map of event data expression (forDomListenerRegistration.addEventData(String)) to Java type, with the same order as the parameters for the event constructor (as returned bygetEventConstructor(Class)).Caches values and automatically uses the cached values when available.
- Parameters:
eventType- the component event type- Returns:
- a map of event expressions, ordered in constructor parameter order
-
getListenerEventData
Gets the event data expressions to add to a DOM listener registration for the given event type, with expressions for components and elements mapped likeDomListenerRegistration.addEventDataElement(String)does.The same unmodifiable list is returned for every call so that all listeners of the event type can share it, see
DomListenerRegistration.addEventData(List).- Parameters:
eventType- the component event type- Returns:
- an unmodifiable list of event data expressions for a DOM listener registration
-
getEventConstructor
Gets the constructor to use for firing a component event, of the given type, based on a DOM event.- Type Parameters:
T- the event type- Parameters:
eventType- the event type- Returns:
- the constructor to use when creating an event from a DOM event
- Throws:
IllegalArgumentException- if no suitable constructor was found
-
isDomEventConstructor
Checks if the given constructor can be used when firing aComponentEventbased on aDomEvent.- Parameters:
constructor- the constructor to check- Returns:
trueif the constructor can be used,falseotherwise
-