public class GenericListener<LISTENER_INTERFACE> extends Object
Constructor and Description |
---|
GenericListener(Class<LISTENER_INTERFACE> clazz)
Constructs the listener.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addListener(LISTENER_INTERFACE listener)
Adds a new listener.
|
boolean |
clear()
Clears all the listeners.
|
void |
forEach(Consumer<? super LISTENER_INTERFACE> action)
Performs the given action for all listeners.
|
boolean |
hasListeners()
Checks if there are any current listeners.
|
LISTENER_INTERFACE[] |
listeners()
Gets a the listeners array.
|
boolean |
removeListener(LISTENER_INTERFACE listener)
Removes a listener.
|
public GenericListener(Class<LISTENER_INTERFACE> clazz)
clazz
- The class instance of the listener interface.public boolean addListener(LISTENER_INTERFACE listener)
listener
- The listener to add.NullPointerException
- If the listener is null
.public boolean removeListener(LISTENER_INTERFACE listener)
listener
- The listener to remove.public boolean hasListeners()
public boolean clear()
public LISTENER_INTERFACE[] listeners()
public void forEach(Consumer<? super LISTENER_INTERFACE> action)
The default implementation behaves as if:
for ( Listener listener: listeners() )
action.accept(listener);
action
- The action to be performed for each listener.NullPointerException
- if the specified action is null
.iizi® is a registered trademark of Mindus SARL. © Copyright 2019 Mindus SARL. All rights reserved.