Package org.djutils.event.util
Class EventProducingListIterator<T>
- java.lang.Object
-
- org.djutils.event.EventProducer
-
- org.djutils.event.util.EventProducingIterator<T>
-
- org.djutils.event.util.EventProducingListIterator<T>
-
- Type Parameters:
T
- the type of elements to iterate on
- All Implemented Interfaces:
Serializable
,Iterator<T>
,ListIterator<T>
,EventProducerInterface
public class EventProducingListIterator<T> extends EventProducingIterator<T> implements ListIterator<T>
EventProducingListIterator provides an iterator embedding the ListIterator, which fires an event when an object has been removed. Note that one does not have to subscribe specifically to the events of the EventProducingListIterator, as the EventProducing collection subscribes to the EventProducingListIterator's remove events and fires these again to its subscribers.Copyright (c) 2002-2021 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:
- Alexander Verbraeck
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static EventType
OBJECT_ADDED_EVENT
OBJECT_ADDED_EVENT is fired on adding of entries.static EventType
OBJECT_CHANGED_EVENT
OBJECT_CHANGED_EVENT is fired on changing of entries.-
Fields inherited from class org.djutils.event.util.EventProducingIterator
OBJECT_REMOVED_EVENT
-
Fields inherited from class org.djutils.event.EventProducer
eventProducerImpl
-
Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
-
-
Constructor Summary
Constructors Constructor Description EventProducingListIterator(ListIterator<T> parent, Serializable sourceId)
constructs a new EventProducingListIterator, embedding the parent ListIterator.EventProducingListIterator(ListIterator<T> parent, IdProvider sourceIdProvider)
Constructs a new EventProducingListIterator, embedding the parent iterator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(T e)
protected ListIterator<T>
getParent()
Return the embedded iterator.boolean
hasPrevious()
int
nextIndex()
T
previous()
int
previousIndex()
void
set(T e)
-
Methods inherited from class org.djutils.event.util.EventProducingIterator
getSourceId, hasNext, next, remove
-
Methods inherited from class org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, 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.Iterator
forEachRemaining
-
Methods inherited from interface java.util.ListIterator
hasNext, next, remove
-
-
-
-
Constructor Detail
-
EventProducingListIterator
public EventProducingListIterator(ListIterator<T> parent, Serializable sourceId)
constructs a new EventProducingListIterator, embedding the parent ListIterator.- Parameters:
parent
- ListIterator<T>; embedded iterator.sourceId
- Serializable; the id by which the EventProducer can be identified by the EventListener
-
EventProducingListIterator
public EventProducingListIterator(ListIterator<T> parent, IdProvider sourceIdProvider)
Constructs a new EventProducingListIterator, embedding the parent iterator.- Parameters:
parent
- ListIterator<T>; the parent set.sourceIdProvider
- IdProvider; the function that produces the id by which the EventProducer can be identified by the EventListener
-
-
Method Detail
-
getParent
protected ListIterator<T> getParent()
Return the embedded iterator.- Overrides:
getParent
in classEventProducingIterator<T>
- Returns:
- parent Iterator<T>; the embedded iterator
-
hasPrevious
public boolean hasPrevious()
- Specified by:
hasPrevious
in interfaceListIterator<T>
-
previous
public T previous()
- Specified by:
previous
in interfaceListIterator<T>
-
nextIndex
public int nextIndex()
- Specified by:
nextIndex
in interfaceListIterator<T>
-
previousIndex
public int previousIndex()
- Specified by:
previousIndex
in interfaceListIterator<T>
-
set
public void set(T e)
- Specified by:
set
in interfaceListIterator<T>
-
add
public void add(T e)
- Specified by:
add
in interfaceListIterator<T>
-
-