package nl.tudelft.simulation.immutablecollections; import java.util.Iterator; /** * An immutable iterator over elements, wrapping a "mutable" iterator. The default remove method from the interface will * throw an exception. *

* Copyright (c) 2016-2018 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 Alexander Verbraeck * @author Peter Knoppers * @author Wouter Schakel * @param the element type */ public class ImmutableIterator implements Iterator { /** the wrapped iterator. */ private final Iterator iterator; /** * @param iterator the iterator to wrap as an immutable iterator. */ public ImmutableIterator(final Iterator iterator) { super(); this.iterator = iterator; } /** {@inheritDoc} */ @Override public final boolean hasNext() { return this.iterator.hasNext(); } /** {@inheritDoc} */ @Override public final E next() { return this.iterator.next(); } /** {@inheritDoc} */ @Override public final String toString() { return "ImmutableIterator [iterator=" + this.iterator + "]"; } }