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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(L listener, boolean weak) Adds anEventListener
which will be notified whenever the an event occurs (something changes).protected abstract void
doAddListener
(EventListener<E> listener) protected abstract boolean
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:EventSource
Adds anEventListener
which 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 sameEventListener
instance may be registered for differentEventSource
s.- Specified by:
addListener
in interfaceEventSource<E,
L extends EventListener<?>> - Parameters:
listener
- theEventListener
to register.weak
- -true
if theEventListener
may be garbage collected without beingremoved
via aWeakReference
,false
otherwise (if the listener will be associated using a strong reference). When providingtrue
here (useWeakReference
), you need to store a reference to your registeredEventListener
yourself in the owning parent object so it is not garbage-collected too early.- See Also:
-
doAddListener
- Parameters:
listener
- theEventListener
to add.
-
fireEvent
- Parameters:
event
- the event tosend
to allregistered
EventListener
s.- Returns:
true
if the event has actually been dispatched,false
otherwise (no listener wasregistered
for the event).
-