public interface EventListenerGroup<T> extends Serializable
Modifier and Type | Method and Description |
---|---|
void |
addDuplicationStrategy(DuplicationStrategy strategy)
Mechanism to more finely control the notion of duplicates.
|
void |
appendListener(T listener) |
void |
appendListeners(T... listeners) |
void |
clear()
Deprecated.
likely want to use
clearListeners() instead, which doesn't
also reset the registered DuplicationStrategy(ies). |
void |
clearListeners()
Removes all registered listeners
|
int |
count() |
<U> void |
fireEventOnEachListener(U event,
BiConsumer<T,U> actionOnEvent)
Similar as
fireLazyEventOnEachListener(Supplier, BiConsumer) except it doesn't use a {Supplier }:
useful when there is no need to lazily initialize the event. |
<R,U,RL> CompletionStage<R> |
fireEventOnEachListener(U event,
Function<RL,Function<U,CompletionStage<R>>> fun)
Similar to
fireEventOnEachListener(Object, Function) , but Reactive friendly: it chains
processing of the same event on each Reactive Listener, and returns a CompletionStage of type R. |
<U,X> void |
fireEventOnEachListener(U event,
X param,
EventActionWithParameter<T,U,X> actionOnEvent)
Similar to
fireEventOnEachListener(Object, BiConsumer) , but allows passing a third parameter
to the consumer; our code based occasionally needs a third parameter: having this additional variant
allows using the optimal iteration more extensively and reduce allocations. |
<R,U,RL,X> CompletionStage<R> |
fireEventOnEachListener(U event,
X param,
Function<RL,BiFunction<U,X,CompletionStage<R>>> fun)
Similar to
fireEventOnEachListener(Object, Object, Function) , but Reactive friendly: it chains
processing of the same event on each Reactive Listener, and returns a CompletionStage of type R. |
<U> void |
fireLazyEventOnEachListener(Supplier<U> eventSupplier,
BiConsumer<T,U> actionOnEvent)
Fires an event on each registered event listener of this group.
|
<R,U,RL> CompletionStage<R> |
fireLazyEventOnEachListener(Supplier<U> eventSupplier,
Function<RL,Function<U,CompletionStage<R>>> fun)
Similar to
fireLazyEventOnEachListener(Supplier, BiConsumer) , but Reactive friendly: it chains
processing of the same event on each Reactive Listener, and returns a CompletionStage of type R. |
EventType<T> |
getEventType()
Retrieve the event type associated with this groups of listeners.
|
boolean |
isEmpty()
Are there no listeners registered?
|
Iterable<T> |
listeners()
Deprecated.
this is not the most efficient way for iterating the event listeners.
See
fireEventOnEachListener(Object, BiConsumer) and its overloaded variants for better alternatives. |
void |
prependListener(T listener) |
void |
prependListeners(T... listeners) |
EventType<T> getEventType()
boolean isEmpty()
int count()
@Deprecated Iterable<T> listeners()
fireEventOnEachListener(Object, BiConsumer)
and its overloaded variants for better alternatives.void addDuplicationStrategy(DuplicationStrategy strategy)
strategy
- The duplication strategyvoid appendListener(T listener)
void appendListeners(T... listeners)
void prependListener(T listener)
void prependListeners(T... listeners)
@Deprecated void clear()
clearListeners()
instead, which doesn't
also reset the registered DuplicationStrategy(ies).void clearListeners()
<U> void fireLazyEventOnEachListener(Supplier<U> eventSupplier, BiConsumer<T,U> actionOnEvent)
U
- the kind of eventeventSupplier
- actionOnEvent
- <U> void fireEventOnEachListener(U event, BiConsumer<T,U> actionOnEvent)
fireLazyEventOnEachListener(Supplier, BiConsumer)
except it doesn't use a {Supplier
}:
useful when there is no need to lazily initialize the event.U
- the kind of eventevent
- actionOnEvent
- <U,X> void fireEventOnEachListener(U event, X param, EventActionWithParameter<T,U,X> actionOnEvent)
fireEventOnEachListener(Object, BiConsumer)
, but allows passing a third parameter
to the consumer; our code based occasionally needs a third parameter: having this additional variant
allows using the optimal iteration more extensively and reduce allocations.U
- X
- event
- param
- actionOnEvent
- <R,U,RL> CompletionStage<R> fireEventOnEachListener(U event, Function<RL,Function<U,CompletionStage<R>>> fun)
fireEventOnEachListener(Object, Function)
, but Reactive friendly: it chains
processing of the same event on each Reactive Listener, and returns a CompletionStage
of type R.
The various generic types allow using this for each concrete event type and flexible return types.
Used by Hibernate Reactive
R
- the return type of the returned CompletionStageU
- the type of the event being fired on each listenerRL
- the type of ReactiveListener: each listener of type T will be casted to it.event
- The event being firedfun
- The function combining each event listener with the event<R,U,RL,X> CompletionStage<R> fireEventOnEachListener(U event, X param, Function<RL,BiFunction<U,X,CompletionStage<R>>> fun)
fireEventOnEachListener(Object, Object, Function)
, but Reactive friendly: it chains
processing of the same event on each Reactive Listener, and returns a CompletionStage
of type R.
The various generic types allow using this for each concrete event type and flexible return types.
Used by Hibernate Reactive
R
- the return type of the returned CompletionStageU
- the type of the event being fired on each listenerRL
- the type of ReactiveListener: each listener of type T will be casted to it.X
- an additional parameter to be passed to the function funevent
- The event being firedfun
- The function combining each event listener with the event<R,U,RL> CompletionStage<R> fireLazyEventOnEachListener(Supplier<U> eventSupplier, Function<RL,Function<U,CompletionStage<R>>> fun)
fireLazyEventOnEachListener(Supplier, BiConsumer)
, but Reactive friendly: it chains
processing of the same event on each Reactive Listener, and returns a CompletionStage
of type R.
The various generic types allow using this for each concrete event type and flexible return types.
This variant expects a Supplier of the event, rather than the event directly; this is useful for the event types which are commonly configured with no listeners at all, so to allow skipping creating the event; use only for event types which are known to be expensive while the listeners are commonly empty.
Used by Hibernate Reactive
R
- the return type of the returned CompletionStageU
- the type of the event being fired on each listenerRL
- the type of ReactiveListener: each listener of type T will be casted to it.eventSupplier
- A supplier able to produce the actual eventfun
- The function combining each event listener with the eventCopyright © 2001-2021 Red Hat, Inc. All Rights Reserved.