Package org.djutils.event.collection
Class EventProducingCollection<T>
java.lang.Object
org.djutils.event.LocalEventProducer
org.djutils.event.collection.EventProducingCollection<T>
- Type Parameters:
T
- The type of the event producing Collection.
- All Implemented Interfaces:
Serializable
,Iterable<T>
,Remote
,Collection<T>
,EventListener
,EventListener
,EventProducer
public class EventProducingCollection<T>
extends LocalEventProducer
implements EventListener, Collection<T>
The Event producing collection 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 on
map.iterator.remove()
. A
listener must subscribe to the iterator individually.
Copyright (c) 2002-2024 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:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final EventType
OBJECT_ADDED_EVENT is fired on new entries.static final EventType
OBJECT_CHANGED_EVENT is fired on change of one or more entries.static final EventType
OBJECT_REMOVED_EVENT is fired on removal of entries.Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION
-
Constructor Summary
ConstructorDescriptionEventProducingCollection
(Collection<T> wrappedCollection) constructs a new EventProducingCollection with a local EventProducer. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends T> c) void
clear()
boolean
boolean
containsAll
(Collection<?> c) boolean
isEmpty()
iterator()
void
Notifies the event listener of an event.boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) int
size()
Object[]
toArray()
<E> E[]
toArray
(E[] 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
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
OBJECT_ADDED_EVENT
OBJECT_ADDED_EVENT is fired on new entries. -
OBJECT_REMOVED_EVENT
OBJECT_REMOVED_EVENT is fired on removal of entries. -
OBJECT_CHANGED_EVENT
OBJECT_CHANGED_EVENT is fired on change of one or more entries.
-
-
Constructor Details
-
EventProducingCollection
constructs a new EventProducingCollection with a local EventProducer.- Parameters:
wrappedCollection
- Collection<T>; the wrapped collection.
-
-
Method Details
-
size
public int size()- Specified by:
size
in interfaceCollection<T>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<T>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<T>
-
add
- Specified by:
add
in interfaceCollection<T>
-
addAll
- Specified by:
addAll
in interfaceCollection<T>
-
contains
- Specified by:
contains
in interfaceCollection<T>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<T>
-
iterator
-
notify
Description copied from interface:EventListener
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:
notify
in interfaceEventListener
- Parameters:
event
- Event; the event which is sent to the listener- Throws:
RemoteException
- If a network connection failure occurs.
-
remove
- Specified by:
remove
in interfaceCollection<T>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<T>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<T>
-
toArray
- Specified by:
toArray
in interfaceCollection<T>
-
toArray
public <E> E[] toArray(E[] a) - Specified by:
toArray
in interfaceCollection<T>
-