Interface MultipartEventBus
MultipartContainer
's.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final class
static final class
static interface
Information on a single registered listener. -
Method Summary
Modifier and TypeMethodDescriptiondefault <E extends MultipartEvent & ContextlessEvent>
MultipartEventBus.ListenerInfo<E>addContextlessListener
(Object key, Class<E> clazz, Runnable listener) Adds a listener for a specifiedMultipartEvent
that also implementsContextlessEvent
with aRunnable
.default <E extends MultipartEvent>
MultipartEventBus.ListenerInfo<E>addExternalListener
(Object key, Class<E> clazz, MultipartEventExternalListener<E> listener) Adds a listener for a specifiedMultipartEvent
(and all of it's subclasses), but also passes theMultipartContainer
that the event was fired from ito the event handler.<E extends MultipartEvent>
MultipartEventBus.ListenerInfo<E>addListener
(Object key, 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
(Object key, Class<E> clazz, Runnable listener) Adds a listener for a specifiedMultipartEvent
that also implementsContextlessEvent
with aRunnable
.boolean
fireEvent
(MultipartEvent event) Fires the given event to all currently registered listeners.List<? extends MultipartEventBus.ListenerInfo<?>>
<E extends MultipartEvent>
List<? extends MultipartEventBus.ListenerInfo<? extends E>>getListeners
(Class<E> clazz) List<MultipartEventBus.ListenerInfo<? extends MultipartEvent>>
getListenersForKey
(Object key) default boolean
default boolean
hasAnyListenersFor
(Class<? extends MultipartEvent> clazz) default boolean
void
removeListeners
(Object key) Removes all listeners that were added for the given key.
-
Method Details
-
getContainer
MultipartContainer getContainer()- Returns:
- The
MultipartContainer
for thisMultipartEventBus
.
-
addListener
<E extends MultipartEvent> MultipartEventBus.ListenerInfo<E> addListener(Object key, 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 theAbstractPart
is re-used, because when that part is removed from theMultipartContainer
removeListeners(Object)
will be called with that part.clazz
- The type of event to listen to.- Throws:
NullPointerException
- if any of the arguments are null.
-
addContextlessListener
default <E extends MultipartEvent & ContextlessEvent> MultipartEventBus.ListenerInfo<E> addContextlessListener(Object key, Class<E> clazz, Runnable listener) Adds a listener for a specifiedMultipartEvent
that also implementsContextlessEvent
with 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 theAbstractPart
is re-used, because when that part is removed from theMultipartContainer
removeListeners(Object)
will be called with that part.clazz
- The type of event to listen to.- Throws:
NullPointerException
- if any of the arguments are null.
-
addRunOnceListener
default <E extends MultipartEvent & ContextlessEvent> MultipartEventBus.ListenerInfo<E> addRunOnceListener(Object key, Class<E> clazz, Runnable listener) Adds a listener for a specifiedMultipartEvent
that also implementsContextlessEvent
with 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 theAbstractPart
is re-used, because when that part is removed from theMultipartContainer
removeListeners(Object)
will be called with that part.clazz
- The type of event to listen to.- Throws:
NullPointerException
- if any of the arguments are null.
-
addExternalListener
default <E extends MultipartEvent> MultipartEventBus.ListenerInfo<E> addExternalListener(Object key, Class<E> clazz, MultipartEventExternalListener<E> listener) Adds a listener for a specifiedMultipartEvent
(and all of it's subclasses), but also passes theMultipartContainer
that 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 theAbstractPart
is re-used, because when that part is removed from theMultipartContainer
removeListeners(Object)
will be called with that part.clazz
- The type of event to listen to.- Throws:
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
Removes all listeners that were added for the given key. -
getListenersForKey
- Parameters:
key
- The identifier that was used inaddListener(Object, Class, EventListener)
.- Returns:
- All listeners that were registered for the given key.
-
hasAnyListenersForKey
-
getListeners
<E extends MultipartEvent> List<? extends MultipartEventBus.ListenerInfo<? extends E>> getListeners(Class<E> clazz) - Returns:
- A list of every
MultipartEventBus.ListenerInfo
that will receive events of the given type.
-
getAllListeners
List<? extends MultipartEventBus.ListenerInfo<?>> getAllListeners()- Returns:
- A list of every
MultipartEventBus.ListenerInfo
current registered to this event bus.
-
hasAnyListenersFor
-
hasAnyListeners
default boolean hasAnyListeners()
-