接口 EventListenerGroup<T>
-
- 所有超级接口:
Serializable
public interface EventListenerGroup<T> extends Serializable
Contract for a groups of events listeners for a particular event type.- 作者:
- Steve Ebersole
-
-
方法概要
所有方法 实例方法 抽象方法 已过时的方法 修饰符和类型 方法 说明 voidaddDuplicationStrategy(DuplicationStrategy strategy)Mechanism to more finely control the notion of duplicates.voidappendListener(T listener)voidappendListeners(T... listeners)voidclear()intcount()<U> voidfireEventOnEachListener(U event, BiConsumer<T,U> actionOnEvent)Similar asfireLazyEventOnEachListener(Supplier, BiConsumer)except it doesn't use a {Supplier}: useful when there is no need to lazily initialize the event.<U,X>
voidfireEventOnEachListener(U event, X param, EventActionWithParameter<T,U,X> actionOnEvent)<U> voidfireLazyEventOnEachListener(Supplier<U> eventSupplier, BiConsumer<T,U> actionOnEvent)Fires an event on each registered event listener of this group.EventType<T>getEventType()Retrieve the event type associated with this groups of listeners.booleanisEmpty()Are there no listeners registered?Iterable<T>listeners()已过时。this is not the most efficient way for iterating the event listeners.voidprependListener(T listener)voidprependListeners(T... listeners)
-
-
-
方法详细资料
-
getEventType
EventType<T> getEventType()
Retrieve the event type associated with this groups of listeners.- 返回:
- The event type.
-
isEmpty
boolean isEmpty()
Are there no listeners registered?- 返回:
- true if no listeners are registered; false otherwise.
-
count
int count()
-
listeners
@Deprecated Iterable<T> listeners()
已过时。this is not the most efficient way for iterating the event listeners. SeefireEventOnEachListener(Object, BiConsumer)and its overloaded variants for better alternatives.- 返回:
- The Iterable.
-
addDuplicationStrategy
void addDuplicationStrategy(DuplicationStrategy strategy)
Mechanism to more finely control the notion of duplicates. For example, say you are registering listeners for an extension library. This extension library could define a "marker interface" which indicates listeners related to it and register a strategy that checks against that marker interface.- 参数:
strategy- The duplication strategy
-
appendListener
void appendListener(T listener)
-
appendListeners
void appendListeners(T... listeners)
-
prependListener
void prependListener(T listener)
-
prependListeners
void prependListeners(T... listeners)
-
clear
void clear()
-
fireLazyEventOnEachListener
<U> void fireLazyEventOnEachListener(Supplier<U> eventSupplier, BiConsumer<T,U> actionOnEvent)
Fires an event on each registered event listener of this group. Implementation note (performance): the first argument is a supplier so that events can avoid allocation when no listener is registered. the second argument is specifically designed to avoid needing a capturing lambda.- 类型参数:
U- the kind of event- 参数:
eventSupplier-actionOnEvent-
-
fireEventOnEachListener
<U> void fireEventOnEachListener(U event, BiConsumer<T,U> actionOnEvent)Similar asfireLazyEventOnEachListener(Supplier, BiConsumer)except it doesn't use a {Supplier}: useful when there is no need to lazily initialize the event.- 类型参数:
U- the kind of event- 参数:
event-actionOnEvent-
-
fireEventOnEachListener
<U,X> void fireEventOnEachListener(U event, X param, EventActionWithParameter<T,U,X> actionOnEvent)
-
-