Package org.djutils.immutablecollections
Class ImmutableAbstractCollection<E>
- java.lang.Object
-
- org.djutils.immutablecollections.ImmutableAbstractCollection<E>
-
- Type Parameters:
E
- the type of content of this Set
- All Implemented Interfaces:
Serializable
,Iterable<E>
,ImmutableCollection<E>
- Direct Known Subclasses:
ImmutableAbstractList
,ImmutableAbstractSet
public abstract class ImmutableAbstractCollection<E> extends Object implements ImmutableCollection<E>
An abstract base class for an immutable wrapper for a Set.Copyright (c) 2016-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.
- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Immutable
copyOrWrap
COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collection.
-
Constructor Summary
Constructors Constructor Description ImmutableAbstractCollection(Immutable copyOrWrap)
Construct an abstract immutable collection.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description protected abstract Collection<E>
getUnderlyingCollection()
Returns the underlying collection of this immutable collection.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.djutils.immutablecollections.ImmutableCollection
contains, containsAll, containsAll, equals, hashCode, isCopy, isEmpty, isWrap, iterator, parallelStream, size, spliterator, stream, toArray, toArray, toCollection
-
-
-
-
Field Detail
-
copyOrWrap
protected final Immutable copyOrWrap
COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collection.
-
-
Constructor Detail
-
ImmutableAbstractCollection
public ImmutableAbstractCollection(Immutable copyOrWrap)
Construct an abstract immutable collection.- Parameters:
copyOrWrap
- Immutable; indicates whether the immutable is a copy or a wrap
-
-
Method Detail
-
getUnderlyingCollection
protected abstract Collection<E> getUnderlyingCollection()
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.- Returns:
- the underlying collection of this immutable collection.
-
-