Package com.tccc.kos.commons.util
Class ListenerList<T>
java.lang.Object
java.util.concurrent.CopyOnWriteArrayList<T>
com.tccc.kos.commons.util.AutowiredList<T>
com.tccc.kos.commons.util.ListenerList<T>
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<T>,Collection<T>,List<T>,RandomAccess
Thread-safe listener list with lambda event support. Uses weak references to
listeners so that there is no need to explicitly unregister the listeners.
- Since:
- 1.0
- Version:
- 2022-08-31
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.tccc.kos.commons.util.AutowiredList
AutowiredList.ChangeListener<S> -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty listener list.ListenerList(Collection<T> listeners) Creates a new listener list containing the specified list of listeners. -
Method Summary
Modifier and TypeMethodDescriptionvoidfireEvent(ListenerCaller<T> caller) Fires an event to listeners of the specified class.<S extends T>
voidfireEvent(Class<S> clazz, ListenerCaller<S> caller) Fires an event to listeners of the specified class.Methods inherited from class com.tccc.kos.commons.util.AutowiredList
add, getOnAdd, getOnRemove, remove, setOnAdd, setOnRemoveMethods inherited from class java.util.concurrent.CopyOnWriteArrayList
add, addAll, addAll, addAllAbsent, addIfAbsent, clear, clone, contains, containsAll, equals, forEach, get, hashCode, indexOf, indexOf, isEmpty, iterator, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, removeAll, removeIf, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, toStringMethods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Constructor Details
-
ListenerList
public ListenerList()Creates a new empty listener list. -
ListenerList
Creates a new listener list containing the specified list of listeners.- Parameters:
listeners- the list of listeners to add
-
-
Method Details
-
fireEvent
Fires an event to listeners of the specified class. -
fireEvent
Fires an event to listeners of the specified class.
-