Module io.github.mmm.event
Package io.github.mmm.event
Class EventSourceAdapter<E,L extends EventListener<?>>
- java.lang.Object
-
- io.github.mmm.event.EventSourceAdapter<E,L>
-
- Type Parameters:
E
- the type of the events to send.L
- the type of thelisteners
.
public abstract class EventSourceAdapter<E,L extends EventListener<?>> extends Object
Adapter forEventSource
.- Since:
- 1.0.0
- See Also:
EventSource
,AbstractEventSource
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract EventSourceAdapter<E,L>
addListener(EventListener<? super E> listener, boolean weak)
static <E,L extends EventListener<?>>
EventSourceAdapter<E,L>empty()
abstract void
fireEvent(E event)
abstract L
getListener(int index)
abstract int
getListenerCount()
abstract EventListener<? super E>
getRawListener(int index)
boolean
hasListeners()
abstract EventSourceAdapter<E,L>
removeListener(EventListener<? super E> listener)
-
-
-
Method Detail
-
addListener
public abstract EventSourceAdapter<E,L> addListener(EventListener<? super E> listener, boolean weak)
- Parameters:
listener
- - seeEventSource.addListener(EventListener)
.weak
- - seeEventSource.addListener(EventListener, boolean)
.- Returns:
- this adapter itself or a new instance capable to handle more listeners.
-
removeListener
public abstract EventSourceAdapter<E,L> removeListener(EventListener<? super E> listener)
- Parameters:
listener
- - seeEventSource.removeListener(EventListener)
.- Returns:
null
if the givenEventListener
was not registered and nothing changed, otherwise this adapter itself or a new instance capable to handle less listeners.
-
fireEvent
public abstract void fireEvent(E event)
- Parameters:
event
- the event tosend
to allregistered
EventListener
s.
-
hasListeners
public boolean hasListeners()
- Returns:
true
if at least oneEventListener
isregistered
,false
otherwise.
-
getListenerCount
public abstract int getListenerCount()
- Returns:
- the number of
registered
EventListener
s.
-
getListener
public abstract L getListener(int index)
- Parameters:
index
- the index of the requestedEventListener
in the range from0
to
.getListenerCount()
- 1- Returns:
- the requested
EventListener
ornull
if index is out of bounds.
-
getRawListener
public abstract EventListener<? super E> getRawListener(int index)
- Parameters:
index
- the index of the requestedEventListener
in the range from0
to
.getListenerCount()
- 1- Returns:
- the requested
EventListener
ornull
if index is out of bounds.
-
empty
public static <E,L extends EventListener<?>> EventSourceAdapter<E,L> empty()
- Type Parameters:
E
- the type of the events to send.L
- the type of thelisteners
.- Returns:
- the empty
EventSourceAdapter
.
-
-