Interface MultipartEventBus
public interface MultipartEventBus
MultipartContainer
's.-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
MultipartEventBus.ContextlessListener<E extends MultipartEvent & ContextlessEvent>
static class
MultipartEventBus.ExternalListener<E extends MultipartEvent>
static interface
MultipartEventBus.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 specifiedMultipartEvent
that also implementsContextlessEvent
with 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 theMultipartContainer
that 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 specifiedMultipartEvent
that also implementsContextlessEvent
with aRunnable
.boolean
fireEvent(MultipartEvent event)
Fires the given event to all currently registered listeners.java.util.List<? extends MultipartEventBus.ListenerInfo<?>>
getAllListeners()
MultipartContainer
getContainer()
<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 boolean
hasAnyListeners()
default boolean
hasAnyListenersFor(java.lang.Class<? extends MultipartEvent> clazz)
default boolean
hasAnyListenersForKey(java.lang.Object key)
void
removeListeners(java.lang.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(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 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:
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 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:
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 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:
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 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:
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.ListenerInfo
that will receive events of the given type.
-
getAllListeners
java.util.List<? extends MultipartEventBus.ListenerInfo<?>> getAllListeners()- Returns:
- A list of every
MultipartEventBus.ListenerInfo
current registered to this event bus.
-
hasAnyListenersFor
-
hasAnyListeners
default boolean hasAnyListeners()
-