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) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights
* reserved.
* BSD-style license. See DSOL License.
*
* $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck
* $, initial version May 7, 2016
* @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();
}