Class ImmutableHashSet<E>

    • Constructor Detail

      • ImmutableHashSet

        public ImmutableHashSet​(Collection<? extends E> collection)
        Construct a new ImmutableHashSet containing a copy of the provided collection.
        Parameters:
        collection - Collection<? extends E>; the collection to use for the immutable set.
      • ImmutableHashSet

        public ImmutableHashSet​(Set<E> set,
                                Immutable copyOrWrap)
        Construct a new ImmutableHashSet containing the provided set.
        Parameters:
        set - Set<E>; the set to use for the immutable set.
        copyOrWrap - COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collection
      • ImmutableHashSet

        public ImmutableHashSet​(ImmutableAbstractCollection<? extends E> collection)
        Construct a new ImmutableHashSet containing a copy of the provided Collection.
        Parameters:
        collection - ImmutableAbstractCollection<? extends E>; the collection to use for the immutable set.
      • ImmutableHashSet

        public ImmutableHashSet​(ImmutableAbstractSet<E> set,
                                Immutable copyOrWrap)
        Construct a new ImmutableHashSet containing the provided set.
        Parameters:
        set - ImmutableAbstractSet<E>; the set to use for the immutable set.
        copyOrWrap - COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collection
    • Method Detail

      • getUnderlyingCollection

        protected Set<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 ImmutableAbstractSet<E>
        Returns:
        the underlying collection of this immutable collection.
      • toSet

        public final Set<E> toSet()
        Returns a modifiable copy of this immutable set.
        Returns:
        a modifiable copy of this immutable set.
      • toString

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