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-2024 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:
  • Field Details

    • copyOrWrap

      protected final Immutable copyOrWrap
      COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collection.
  • Constructor Details

    • ImmutableAbstractCollection

      public ImmutableAbstractCollection(Immutable copyOrWrap)
      Construct an abstract immutable collection.
      Parameters:
      copyOrWrap - Immutable; indicates whether the immutable is a copy or a wrap
  • Method Details

    • 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.