Interface ImmutableSet<E>

Type Parameters:
E - The type of items contained in this set.
All Superinterfaces:
ImmutableCollection<E>, Iterable<E>
All Known Implementing Classes:
ImmutableHashSet

public interface ImmutableSet<E> extends ImmutableCollection<E>
Immutable set with a functional API.
Author:
ActiveViam
  • Method Details

    • add

      ImmutableSet<E> add(E e)
      Description copied from interface: ImmutableCollection
      Create a new collection having the items of this collection plus one new item.
      Specified by:
      add in interface ImmutableCollection<E>
      Parameters:
      e - The items to add.
      Returns:
      The new collection.
    • add

      ImmutableSet<E> add(E first, E second, E... rest)
      Description copied from interface: ImmutableCollection
      Create a new collection having the items of this collection plus new items.
      Specified by:
      add in interface ImmutableCollection<E>
      Parameters:
      first - The first item to add.
      second - The second item to add.
      rest - The other items to add.
      Returns:
      The new collection.
    • map

      <R> ImmutableSet<R> map(Function<E,R> mapper)
      Map this set.
      Type Parameters:
      R - The type returned by the mapper.
      Parameters:
      mapper - The mapping function.
      Returns:
      The set containing the mapped elements.
      See Also:
    • flatMap

      <R> ImmutableSet<R> flatMap(Function<E,Iterable<R>> mapper)
      Flat map this set.
      Specified by:
      flatMap in interface ImmutableCollection<E>
      Type Parameters:
      R - The type returned by the mapper.
      Parameters:
      mapper - The mapping function.
      Returns:
      The set containing the mapped elements.
      See Also:
    • toList

      ImmutableList<E> toList()
      Create a read-only java util list from this set.
      Returns:
      The list.
    • toSet

      Set<E> toSet()
      Create a read-only java util set from this set.
      Returns:
      The set.
    • filter

      ImmutableSet<E> filter(Predicate<E> predicate)
      Filter the items from this set with a predicate.
      Parameters:
      predicate - The predicate filtering the items.
      Returns:
      The set containing only the items that matched the predicate.
    • toMap

      <V> ImmutableMap<E,V> toMap(Function<E,V> mapper)
      Map the items of this set.
      Type Parameters:
      V - The type returned by the mapper.
      Parameters:
      mapper - The mapping function that will be applied to each item of this set.
      Returns:
      The set containing the mapped items.
    • addAll

      ImmutableSet<E> addAll(Collection<? extends E> col)
      Description copied from interface: ImmutableCollection
      Create a new collection having the items of this collection plus items from another collection.
      Specified by:
      addAll in interface ImmutableCollection<E>
      Parameters:
      col - The items to add.
      Returns:
      The new collection.
    • addAll

      default ImmutableSet<E> addAll(ImmutableSet<E> set)
      Create a new set having the items of this collection plus items from another set.
      Parameters:
      set - The items to add.
      Returns:
      The new set.
    • addAll

      default ImmutableSet<E> addAll(ImmutableCollection<E> col)
      Description copied from interface: ImmutableCollection
      Create a new collection having the items of this collection plus items from another collection.
      Specified by:
      addAll in interface ImmutableCollection<E>
      Parameters:
      col - The items to add.
      Returns:
      The new collection.
    • debug

      default ImmutableSet<E> debug(String prefix)
      Prints the content of this collection to System.out and return itself. Useful for debugging inside chained calls.
      Parameters:
      prefix - The prefix to print before the collection.
      Returns:
      The collection itself.
    • join

      default String join(String separator)
      Concatenate the toString() of all the items in this set separated by a separator.
      Parameters:
      separator - The string to place between each item's string representation. Cannot be null.
      Returns:
      The string formed by the concatenation of all the members with the separator.