package nl.tudelft.simulation.immutablecollections; import java.util.Collection; import nl.tudelft.simulation.language.Throw; /** * An abstract base class for an immutable wrapper for a Set. *

* 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 type of content of this Set */ public abstract class ImmutableAbstractCollection implements ImmutableCollection { /** */ private static final long serialVersionUID = 20180908L; /** COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collection. */ protected final Immutable copyOrWrap; /** * Construct an abstract immutable collection. * @param copyOrWrap indicates whether the immutable is a copy or a wrap */ public ImmutableAbstractCollection(final Immutable copyOrWrap) { Throw.whenNull(copyOrWrap, "the copyOrWrap argument should be Immutable.COPY or Immutable.WRAP"); this.copyOrWrap = copyOrWrap; } /** * Returns the underlying collection of this immutable collection. In case of Immutable.WRAP, this will be the * original collection. In case of IMMUTABLE.COPY, this will be the internally stored (mutable) copy of the * collection. * @return the underlying collection of this immutable collection. */ protected abstract Collection getCollection(); }