Class ImmutableSetFacade<E>

Type Parameters:
E - the element type
All Implemented Interfaces:
Iterable<E>, ImmutableCollection<E>, ImmutableSet<E>, ReadOnlyCollection<E>, ReadOnlySet<E>

public class ImmutableSetFacade<E> extends AbstractReadOnlySet<E> implements ImmutableSet<E>
Provides a ImmutableSet facade to a set of ImmutableSet functions.
  • Constructor Details

    • ImmutableSetFacade

      public ImmutableSetFacade(Set<E> target, Function<Set<E>,Set<E>> cloneFunction)
  • Method Details

    • empty

      public <T> ImmutableSet<T> empty()
      Description copied from interface: ImmutableSet
      Returns an empty set instance that has the specified element type.
      Specified by:
      empty in interface ImmutableCollection<E>
      Specified by:
      empty in interface ImmutableSet<E>
      Type Parameters:
      T - the element type of the returned set
      Returns:
      an empty set of the specified element type.
    • add

      public ImmutableSet<E> add(E element)
      Description copied from interface: ImmutableSet
      Returns a copy of this set that contains all elements of this set and also the specified element.
      Specified by:
      add in interface ImmutableCollection<E>
      Specified by:
      add in interface ImmutableSet<E>
      Parameters:
      element - an element
      Returns:
      this set instance if it already contains the element, or a different set instance with the element added
    • addAll

      public ImmutableSet<E> addAll(Iterable<? extends E> c)
      Description copied from interface: ImmutableSet
      Returns a copy of this set that contains all elements of this set and also all elements of the specified collection.
      Specified by:
      addAll in interface ImmutableCollection<E>
      Specified by:
      addAll in interface ImmutableSet<E>
      Parameters:
      c - a collection to be added to this set
      Returns:
      this set instance if it already contains the elements, or a different set instance with the elements added
    • remove

      public ImmutableSet<E> remove(E element)
      Description copied from interface: ImmutableSet
      Returns a copy of this set that contains all elements of this set except the specified element.
      Specified by:
      remove in interface ImmutableCollection<E>
      Specified by:
      remove in interface ImmutableSet<E>
      Parameters:
      element - an element
      Returns:
      this set instance if it already does not contain the element, or a different set instance with the element removed
    • removeAll

      public ImmutableSet<E> removeAll(Iterable<?> c)
      Description copied from interface: ImmutableSet
      Returns a copy of this set that contains all elements of this set except the elements of the specified collection.
      Specified by:
      removeAll in interface ImmutableCollection<E>
      Specified by:
      removeAll in interface ImmutableSet<E>
      Parameters:
      c - a collection with elements to be removed from this set
      Returns:
      this set instance if it already does not contain the elements, or a different set instance with the elements removed
    • retainAll

      public ImmutableSet<E> retainAll(Iterable<?> c)
      Description copied from interface: ImmutableSet
      Returns a copy of this set that contains only elements that are in this set and in the specified collection.
      Specified by:
      retainAll in interface ImmutableCollection<E>
      Specified by:
      retainAll in interface ImmutableSet<E>
      Parameters:
      c - a collection with elements to be retained in this set
      Returns:
      this set instance if it has not changed, or a different set instance with elements removed
    • size

      public int size()
      Description copied from interface: ReadOnlyCollection
      Returns the size of the collection.
      Specified by:
      size in interface ReadOnlyCollection<E>
      Returns:
      the size
    • contains

      public boolean contains(Object o)
      Description copied from interface: ReadOnlyCollection
      Returns true if this collection contains the specified object.
      Specified by:
      contains in interface ReadOnlyCollection<E>
      Overrides:
      contains in class AbstractReadOnlyCollection<E>
      Parameters:
      o - an object
      Returns:
      true if this collection contains the specified object
    • maxSize

      public int maxSize()
      Description copied from interface: ImmutableCollection
      Returns the maximal number of elements that this collection type can hold
      Specified by:
      maxSize in interface ImmutableCollection<E>
      Returns:
      the maximal size
    • iterator

      public Iterator<E> iterator()
      Description copied from interface: ReadOnlyCollection
      Returns an iterator over the elements in this collection.
      Specified by:
      iterator in interface Iterable<E>
      Specified by:
      iterator in interface ReadOnlyCollection<E>
      Returns:
      an iterator
    • spliterator

      public Spliterator<E> spliterator()
      Specified by:
      spliterator in interface Iterable<E>
    • toMutable

      public Set<E> toMutable()
      Description copied from interface: ImmutableSet
      Returns a mutable copy of this set.
      Specified by:
      toMutable in interface ImmutableCollection<E>
      Specified by:
      toMutable in interface ImmutableSet<E>
      Returns:
      a mutable copy.
    • characteristics

      public int characteristics()
      Description copied from interface: ReadOnlySet
      Returns the Spliterator characteristics of this collection.

      The default implementation returns Spliterator.SIZED| Spliterator.DISTINCT.

      Specified by:
      characteristics in interface ReadOnlyCollection<E>
      Specified by:
      characteristics in interface ReadOnlySet<E>
      Returns:
      the characteristics