Package org.djutils.event.collection
Class EventProducingSet<E>
- java.lang.Object
-
- org.djutils.event.LocalEventProducer
-
- org.djutils.event.collection.EventProducingSet<E>
-
- Type Parameters:
E- the type of elements in the set
- All Implemented Interfaces:
Serializable,Iterable<E>,Remote,Collection<E>,EventListener,Set<E>,EventListener,EventProducer
public class EventProducingSet<E> extends LocalEventProducer implements EventListener, Set<E>
The Event producing set provides a set to which one can subscribe interest in entry changes. This class does not keep track of changes which take place indirectly. One is for example not notified onmap.iterator.remove(). A listener must subscribe to the iterator individually.Copyright (c) 2002-2023 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html. This class was originally part of the DSOL project, see https://simulation.tudelft.nl/dsol/manual.
- Author:
- Peter Jacobs , Alexander Verbraeck
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static EventTypeOBJECT_ADDED_EVENTOBJECT_ADDED_EVENT is fired on new entries.static EventTypeOBJECT_CHANGED_EVENTOBJECT_CHANGED_EVENT is fired on change of one or more entries.static EventTypeOBJECT_REMOVED_EVENTOBJECT_REMOVED_EVENT is fired on removal of entries.-
Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION
-
-
Constructor Summary
Constructors Constructor Description EventProducingSet(Set<E> wrappedSet)Constructs a new EventProducingSet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E o)booleanaddAll(Collection<? extends E> c)voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> c)booleanisEmpty()EventProducingIterator<E>iterator()voidnotify(Event event)Notifies the event listener of an event.booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)intsize()Object[]toArray()<T> T[]toArray(T[] a)-
Methods inherited from class org.djutils.event.LocalEventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventListenerMap, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
equals, hashCode, spliterator
-
-
-
-
Field Detail
-
OBJECT_ADDED_EVENT
public static final EventType OBJECT_ADDED_EVENT
OBJECT_ADDED_EVENT is fired on new entries.
-
OBJECT_REMOVED_EVENT
public static final EventType OBJECT_REMOVED_EVENT
OBJECT_REMOVED_EVENT is fired on removal of entries.
-
OBJECT_CHANGED_EVENT
public static final EventType OBJECT_CHANGED_EVENT
OBJECT_CHANGED_EVENT is fired on change of one or more entries.
-
-
Method Detail
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
clear
public void clear()
-
add
public boolean add(E o)
-
addAll
public boolean addAll(Collection<? extends E> c)
-
contains
public boolean contains(Object o)
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceSet<E>
-
iterator
public EventProducingIterator<E> iterator()
-
notify
public void notify(Event event) throws RemoteException
Notifies the event listener of an event. This operation forms the callback method of the asynchronous communication protocol expressed in the event package.- Specified by:
notifyin interfaceEventListener- Parameters:
event- Event; the event which is sent to the listener- Throws:
RemoteException- If a network connection failure occurs.
-
remove
public boolean remove(Object o)
-
removeAll
public boolean removeAll(Collection<?> c)
-
retainAll
public boolean retainAll(Collection<?> c)
-
toArray
public Object[] toArray()
-
-