Class ImmutableArrayList<E>

    • Constructor Detail

      • ImmutableArrayList

        public ImmutableArrayList​(Collection<? extends E> collection)
        Parameters:
        collection - Collection<? extends E>; the collection to use for the immutable list.
      • ImmutableArrayList

        public ImmutableArrayList​(List<E> list,
                                  Immutable copyOrWrap)
        Parameters:
        list - List<E>; the list to use for the immutable list.
        copyOrWrap - COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collection
      • ImmutableArrayList

        public ImmutableArrayList​(ImmutableAbstractCollection<? extends E> collection)
        Parameters:
        collection - ImmutableAbstractCollection<? extends E>; the collection to use for the immutable list.
      • ImmutableArrayList

        public ImmutableArrayList​(ImmutableAbstractList<E> list,
                                  Immutable copyOrWrap)
        Parameters:
        list - ImmutableAbstractList<E>; the list to use for the immutable list.
        copyOrWrap - COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collection
    • Method Detail

      • toList

        public final ArrayList<E> toList()
        Returns a modifiable copy of this immutable list.
        Returns:
        a modifiable copy of this immutable list.
      • getUnderlyingCollection

        protected List<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.
        Overrides:
        getUnderlyingCollection in class ImmutableAbstractList<E>
        Returns:
        the underlying collection of this immutable collection.
      • subList

        public final ImmutableList<E> subList​(int fromIndex,
                                              int toIndex)
        Returns a safe, immutable copy of the portion of this immutable list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned immutable list is empty).
        Parameters:
        fromIndex - int; low endpoint (inclusive) of the subList
        toIndex - int; high endpoint (exclusive) of the subList
        Returns:
        a view of the specified range within this immutable list
      • toString

        public final String toString()
        Force to redefine toString.
        Specified by:
        toString in interface ImmutableList<E>
        Overrides:
        toString in class Object
        Returns:
        String; a description of this immutable list