Package com.activeviam.collections
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 Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ImmutableSet<E>add(E e)Create a new collection having the items of this collection plus one new item.ImmutableSet<E>add(E first, E second, E... rest)Create a new collection having the items of this collection plus new items.default ImmutableSet<E>addAll(ImmutableCollection<E> col)Create a new collection having the items of this collection plus items from another collection.default ImmutableSet<E>addAll(ImmutableSet<E> set)Create a new set having the items of this collection plus items from another set.ImmutableSet<E>addAll(Collection<? extends E> col)Create a new collection having the items of this collection plus items from another collection.default ImmutableSet<E>debug(String prefix)Prints the content of this collection to System.out and return itself.ImmutableSet<E>filter(Predicate<E> predicate)Filter the items from this set with a predicate.<R> ImmutableSet<R>flatMap(Function<E,Iterable<R>> mapper)Flat map this set.default Stringjoin(String separator)Concatenate thetoString()of all the items in this set separated by a separator.<R> ImmutableSet<R>map(Function<E,R> mapper)Map this set.ImmutableList<E>toList()Create a read-only java util list from this set.<V> ImmutableMap<E,V>toMap(Function<E,V> mapper)Map the items of this set.Set<E>toSet()Create a read-only java util set from this set.-
Methods inherited from interface com.activeviam.collections.ImmutableCollection
addAll, contains, doesNotContain, every, find, findIndex, first, forEach, forEachUntil, getFirst, isEmpty, isNotEmpty, reduce, size, some, toArray, toArray, toCollection
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
add
ImmutableSet<E> add(E e)
Description copied from interface:ImmutableCollectionCreate a new collection having the items of this collection plus one new item.- Specified by:
addin interfaceImmutableCollection<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:ImmutableCollectionCreate a new collection having the items of this collection plus new items.- Specified by:
addin interfaceImmutableCollection<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:
Stream.map(Function)
-
flatMap
<R> ImmutableSet<R> flatMap(Function<E,Iterable<R>> mapper)
Flat map this set.- Specified by:
flatMapin interfaceImmutableCollection<E>- Type Parameters:
R- The type returned by the mapper.- Parameters:
mapper- The mapping function.- Returns:
- The set containing the mapped elements.
- See Also:
Stream.flatMap(Function)
-
toList
ImmutableList<E> toList()
Create a read-only java util list from this set.- Returns:
- The list.
-
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:ImmutableCollectionCreate a new collection having the items of this collection plus items from another collection.- Specified by:
addAllin interfaceImmutableCollection<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:ImmutableCollectionCreate a new collection having the items of this collection plus items from another collection.- Specified by:
addAllin interfaceImmutableCollection<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 thetoString()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.
-
-