Module io.github.mmm.event
Package io.github.mmm.event
Class AbstractEventSource<E,L extends EventListener<?>>
java.lang.Object
io.github.mmm.event.AbstractEventSource<E,L>
- All Implemented Interfaces:
EventSource<E,L>
- Direct Known Subclasses:
AbstractEventBus.EventDispatcher,AbstractEventSender
public abstract class AbstractEventSource<E,L extends EventListener<?>>
extends Object
implements EventSource<E,L>
Implementation of
EventSource.- Since:
- 1.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(L listener, boolean weak) Adds anEventListenerwhich will be notified whenever the an event occurs (something changes).protected abstract voiddoAddListener(EventListener<E> listener) protected abstract booleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.mmm.event.EventSource
addListener, addWeakListener, removeListener
-
Constructor Details
-
AbstractEventSource
public AbstractEventSource()The constructor.
-
-
Method Details
-
addListener
Description copied from interface:EventSourceAdds anEventListenerwhich will be notified whenever the an event occurs (something changes). If the same listener is added more than once, it will be notified more than once. The sameEventListenerinstance may be registered for differentEventSources.- Specified by:
addListenerin interfaceEventSource<E,L extends EventListener<?>> - Parameters:
listener- theEventListenerto register.weak- -trueif theEventListenermay be garbage collected without beingremovedvia aWeakReference,falseotherwise (if the listener will be associated using a strong reference). When providingtruehere (useWeakReference), you need to store a reference to your registeredEventListeneryourself in the owning parent object so it is not garbage-collected too early.- See Also:
-
doAddListener
- Parameters:
listener- theEventListenerto add.
-
fireEvent
- Parameters:
event- the event tosendto allregisteredEventListeners.- Returns:
trueif the event has actually been dispatched,falseotherwise (no listener wasregisteredfor the event).
-