Package org.jboss.weld.util.collections
Class ImmutableSet<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<T>
org.jboss.weld.util.collections.ImmutableSet<T>
- Type Parameters:
T- the type of elements
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Set<T>
- Direct Known Subclasses:
ImmutableHashSet
Weld's immutable set implementation. Instances returned from methods of this class may use different strategies to achieve
good performance / memory
consumption balance.
These strategies include:
- Author:
- Jozef Hartinger
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceBuilder for building immutable sets. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends T> c) static <T> ImmutableSet.Builder<T>builder()Creates a new empty builder for building immutable sets.voidclear()static <T> org.jboss.weld.util.collections.ImmutableSet.ImmutableSetCollector<T>Returns a collector that can be used to collect items of a stream into an immutable set.booleancontainsAll(Collection<?> c) static <T> Set<T>copyOf(Collection<? extends T> collection) Creates a new immutable set that consists of the elements in the given collection.booleanbooleanisEmpty()static <T> Set<T>of(T... elements) Creates a new immutable set that consists of given elements.booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) Methods inherited from class java.util.AbstractSet
hashCodeMethods inherited from class java.util.AbstractCollection
contains, iterator, size, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Method Details
-
copyOf
Creates a new immutable set that consists of the elements in the given collection. If the given collection is already an instance created byImmutableSet, the instance is re-used.- Parameters:
collection- the given collection- Returns:
- a new immutable set that consists of the elements in the given collection
-
of
Creates a new immutable set that consists of given elements.- Parameters:
elements- the given elements- Returns:
- a new immutable set that consists of given elements
-
collector
public static <T> org.jboss.weld.util.collections.ImmutableSet.ImmutableSetCollector<T> collector()Returns a collector that can be used to collect items of a stream into an immutable set.- Returns:
- collector
-
builder
Creates a new empty builder for building immutable sets.- Returns:
- a new empty builder
-
add
- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceSet<T>- Overrides:
addin classAbstractCollection<T>
-
remove
- Specified by:
removein interfaceCollection<T>- Specified by:
removein interfaceSet<T>- Overrides:
removein classAbstractCollection<T>
-
addAll
- Specified by:
addAllin interfaceCollection<T>- Specified by:
addAllin interfaceSet<T>- Overrides:
addAllin classAbstractCollection<T>
-
retainAll
- Specified by:
retainAllin interfaceCollection<T>- Specified by:
retainAllin interfaceSet<T>- Overrides:
retainAllin classAbstractCollection<T>
-
removeAll
- Specified by:
removeAllin interfaceCollection<T>- Specified by:
removeAllin interfaceSet<T>- Overrides:
removeAllin classAbstractSet<T>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<T>- Specified by:
clearin interfaceSet<T>- Overrides:
clearin classAbstractCollection<T>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<T>- Specified by:
isEmptyin interfaceSet<T>- Overrides:
isEmptyin classAbstractCollection<T>
-
containsAll
- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceSet<T>- Overrides:
containsAllin classAbstractCollection<T>
-
equals
- Specified by:
equalsin interfaceCollection<T>- Specified by:
equalsin interfaceSet<T>- Overrides:
equalsin classAbstractSet<T>
-
spliterator
- Specified by:
spliteratorin interfaceCollection<T>- Specified by:
spliteratorin interfaceIterable<T>- Specified by:
spliteratorin interfaceSet<T>
-