Interface MultipartEventBus
public interface MultipartEventBus
MultipartContainer's.-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classMultipartEventBus.ContextlessListener<E extends MultipartEvent & ContextlessEvent>static classMultipartEventBus.ExternalListener<E extends MultipartEvent>static interfaceMultipartEventBus.ListenerInfo<E extends MultipartEvent>Information on a single registered listener. -
Method Summary
Modifier and Type Method Description default <E extends MultipartEvent & ContextlessEvent>
MultipartEventBus.ListenerInfo<E>addContextlessListener(java.lang.Object key, java.lang.Class<E> clazz, java.lang.Runnable listener)Adds a listener for a specifiedMultipartEventthat also implementsContextlessEventwith aRunnable.default <E extends MultipartEvent>
MultipartEventBus.ListenerInfo<E>addExternalListener(java.lang.Object key, java.lang.Class<E> clazz, MultipartEventExternalListener<E> listener)Adds a listener for a specifiedMultipartEvent(and all of it's subclasses), but also passes theMultipartContainerthat the event was fired from ito the event handler.<E extends MultipartEvent>
MultipartEventBus.ListenerInfo<E>addListener(java.lang.Object key, java.lang.Class<E> clazz, EventListener<E> listener)Adds a listener for a specifiedMultipartEvent(and all of it's subclasses).default <E extends MultipartEvent & ContextlessEvent>
MultipartEventBus.ListenerInfo<E>addRunOnceListener(java.lang.Object key, java.lang.Class<E> clazz, java.lang.Runnable listener)Adds a listener for a specifiedMultipartEventthat also implementsContextlessEventwith aRunnable.booleanfireEvent(MultipartEvent event)Fires the given event to all currently registered listeners.java.util.List<? extends MultipartEventBus.ListenerInfo<?>>getAllListeners()MultipartContainergetContainer()<E extends MultipartEvent>
java.util.List<? extends MultipartEventBus.ListenerInfo<? extends E>>getListeners(java.lang.Class<E> clazz)java.util.List<MultipartEventBus.ListenerInfo<? extends MultipartEvent>>getListenersForKey(java.lang.Object key)default booleanhasAnyListeners()default booleanhasAnyListenersFor(java.lang.Class<? extends MultipartEvent> clazz)default booleanhasAnyListenersForKey(java.lang.Object key)voidremoveListeners(java.lang.Object key)Removes all listeners that were added for the given key.
-
Method Details
-
getContainer
MultipartContainer getContainer()- Returns:
- The
MultipartContainerfor thisMultipartEventBus.
-
addListener
<E extends MultipartEvent> MultipartEventBus.ListenerInfo<E> addListener(java.lang.Object key, java.lang.Class<E> clazz, EventListener<E> listener)Adds a listener for a specifiedMultipartEvent(and all of it's subclasses).This makes only one guarantee for event listener ordering: all listeners added for the same key will be called in the order that they are registered.
- Parameters:
key- The identifier for the listener, compared with identity equality (==) and not object equality. Multiple listeners can be added with the same key. If the caller is anAbstractPart, and contained within this event bus'sgetContainer()then it is strongly recommended that theAbstractPartis re-used, because when that part is removed from theMultipartContainerremoveListeners(Object)will be called with that part.clazz- The type of event to listen to.- Throws:
java.lang.NullPointerException- if any of the arguments are null.
-
addContextlessListener
default <E extends MultipartEvent & ContextlessEvent> MultipartEventBus.ListenerInfo<E> addContextlessListener(java.lang.Object key, java.lang.Class<E> clazz, java.lang.Runnable listener)Adds a listener for a specifiedMultipartEventthat also implementsContextlessEventwith aRunnable.This makes only one guarantee for event listener ordering: all listeners added for the same key will be called in the order that they are registered.
- Parameters:
key- The identifier for the listener, compared with identity equality (==) and not object equality. Multiple listeners can be added with the same key. If the caller is anAbstractPart, and contained within this event bus'sgetContainer()then it is strongly recommended that theAbstractPartis re-used, because when that part is removed from theMultipartContainerremoveListeners(Object)will be called with that part.clazz- The type of event to listen to.- Throws:
java.lang.NullPointerException- if any of the arguments are null.
-
addRunOnceListener
default <E extends MultipartEvent & ContextlessEvent> MultipartEventBus.ListenerInfo<E> addRunOnceListener(java.lang.Object key, java.lang.Class<E> clazz, java.lang.Runnable listener)Adds a listener for a specifiedMultipartEventthat also implementsContextlessEventwith aRunnable.This makes only one guarantee for event listener ordering: all listeners added for the same key will be called in the order that they are registered.
After the event has been fired once the listener will be removed, which means that the given listener will only be called once (at most).
- Parameters:
key- The identifier for the listener, compared with identity equality (==) and not object equality. Multiple listeners can be added with the same key. If the caller is anAbstractPart, and contained within this event bus'sgetContainer()then it is strongly recommended that theAbstractPartis re-used, because when that part is removed from theMultipartContainerremoveListeners(Object)will be called with that part.clazz- The type of event to listen to.- Throws:
java.lang.NullPointerException- if any of the arguments are null.
-
addExternalListener
default <E extends MultipartEvent> MultipartEventBus.ListenerInfo<E> addExternalListener(java.lang.Object key, java.lang.Class<E> clazz, MultipartEventExternalListener<E> listener)Adds a listener for a specifiedMultipartEvent(and all of it's subclasses), but also passes theMultipartContainerthat the event was fired from ito the event handler.This makes only one guarantee for event listener ordering: all listeners added for the same key will be called in the order that they are registered.
- Parameters:
key- The identifier for the listener, compared with identity equality (==) and not object equality. Multiple listeners can be added with the same key. If the caller is anAbstractPart, and contained within this event bus'sgetContainer()then it is strongly recommended that theAbstractPartis re-used, because when that part is removed from theMultipartContainerremoveListeners(Object)will be called with that part.clazz- The type of event to listen to.- Throws:
java.lang.NullPointerException- if any of the arguments are null.
-
fireEvent
Fires the given event to all currently registered listeners.- Returns:
- True if any listeners received the given event, false if none did. This may be useful for optimisation purposes.
-
removeListeners
void removeListeners(java.lang.Object key)Removes all listeners that were added for the given key. -
getListenersForKey
java.util.List<MultipartEventBus.ListenerInfo<? extends MultipartEvent>> getListenersForKey(java.lang.Object key)- Parameters:
key- The identifier that was used inaddListener(Object, Class, EventListener).- Returns:
- All listeners that were registered for the given key.
-
hasAnyListenersForKey
default boolean hasAnyListenersForKey(java.lang.Object key) -
getListeners
<E extends MultipartEvent> java.util.List<? extends MultipartEventBus.ListenerInfo<? extends E>> getListeners(java.lang.Class<E> clazz)- Returns:
- A list of every
MultipartEventBus.ListenerInfothat will receive events of the given type.
-
getAllListeners
java.util.List<? extends MultipartEventBus.ListenerInfo<?>> getAllListeners()- Returns:
- A list of every
MultipartEventBus.ListenerInfocurrent registered to this event bus.
-
hasAnyListenersFor
-
hasAnyListeners
default boolean hasAnyListeners()
-