package nl.tudelft.simulation.event.util; import java.util.Iterator; import nl.tudelft.simulation.event.EventProducer; import nl.tudelft.simulation.event.EventType; /** * The Event producing iterator provides a set to which one can subscribe interest in entry changes. *

* Copyright (c) 2002-2019 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See * for project information https://simulation.tudelft.nl. The DSOL * project is distributed under a three-clause BSD-style license, which can be found at * * https://simulation.tudelft.nl/dsol/3.0/license.html. *

* @author Peter Jacobs * @author Alexander Verbraeck * @since 1.5 * @param the type of the iterator */ public class EventIterator extends EventProducer implements Iterator { /** The default serial version UID for serializable classes. */ private static final long serialVersionUID = 1L; /** OBJECT_REMOVED_EVENT is fired on removal of entries. */ public static final EventType OBJECT_REMOVED_EVENT = new EventType("OBJECT_REMOVED_EVENT"); /** our parent iterator. */ private Iterator parent = null; /** * constructs a new Iterator. * @param parent Iterator<T>; parent. */ public EventIterator(final Iterator parent) { super(); this.parent = parent; } /** {@inheritDoc} */ @Override public boolean hasNext() { return this.parent.hasNext(); } /** {@inheritDoc} */ @Override public T next() { return this.parent.next(); } /** {@inheritDoc} */ @Override public void remove() { this.parent.remove(); this.fireEvent(OBJECT_REMOVED_EVENT); } }