Package org.djutils.event.util
Class EventProducingList<E>
java.lang.Object
org.djutils.event.EventProducer
org.djutils.event.util.EventProducingList<E>
- Type Parameters:
E- the type of elements in the list
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,EventListener,List<E>,EventListenerInterface,EventProducerInterface
public class EventProducingList<E> extends EventProducer implements EventListenerInterface, List<E>
The Event producing list provides a list 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-2020 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 removel of entries.Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION -
Constructor Summary
Constructors Constructor Description EventProducingList(List<E> parent, Serializable sourceId)constructs a new EventProducingList.EventProducingList(List<E> parent, IdProvider sourceIdProvider)Constructs a new EventProducingList. -
Method Summary
Modifier and Type Method Description voidadd(int index, E element)booleanadd(E o)booleanaddAll(int index, Collection<? extends E> c)booleanaddAll(Collection<? extends E> c)voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> c)Eget(int index)SerializablegetSourceId()Provide the sourceId that will be transmitted with the fired Event.intindexOf(Object o)booleanisEmpty()EventProducingIterator<E>iterator()intlastIndexOf(Object o)EventProducingListIterator<E>listIterator()EventProducingListIterator<E>listIterator(int index)voidnotify(EventInterface event)Notifies the event listener of an event.Eremove(int index)booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)Eset(int index, E element)intsize()List<E>subList(int fromIndex, int toIndex)Object[]toArray()<T> T[]toArray(T[] a)Methods inherited from class org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
Field Details
-
OBJECT_ADDED_EVENT
OBJECT_ADDED_EVENT is fired on new entries. -
OBJECT_REMOVED_EVENT
OBJECT_REMOVED_EVENT is fired on removel of entries. -
OBJECT_CHANGED_EVENT
OBJECT_CHANGED_EVENT is fired on change of one or more entries.
-
-
Constructor Details
-
EventProducingList
constructs a new EventProducingList.- Parameters:
parent- List<E>; the parent list.sourceId- Serializable; the id by which the EventProducer can be identified by the EventListener
-
EventProducingList
Constructs a new EventProducingList.- Parameters:
parent- List<E>; the parent set.sourceIdProvider- IdProvider; the function that produces the id by which the EventProducer can be identified by the EventListener
-
-
Method Details
-
getSourceId
Provide the sourceId that will be transmitted with the fired Event.- Specified by:
getSourceIdin interfaceEventProducerInterface- Specified by:
getSourceIdin classEventProducer- Returns:
- Serializable; the sourceId that will be transmitted with the fired Event
-
size
public int size() -
isEmpty
public boolean isEmpty() -
clear
public void clear() -
add
-
add
-
addAll
-
addAll
-
contains
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>
-
get
-
indexOf
-
iterator
-
listIterator
- Specified by:
listIteratorin interfaceList<E>
-
listIterator
- Specified by:
listIteratorin interfaceList<E>
-
notify
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 interfaceEventListenerInterface- Parameters:
event- EventInterface; the event which is sent to the listener- Throws:
RemoteException- If a network connection failure occurs.
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<E>
-
remove
-
remove
-
removeAll
-
retainAll
-
set
-
subList
-
toArray
-
toArray
public <T> T[] toArray(T[] a)
-