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
public abstract class ImmutableSet<T> extends AbstractSet<T>
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 Classes Modifier and Type Class Description static interfaceImmutableSet.Builder<T>Builder for building immutable sets.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(T e)booleanaddAll(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>collector()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.booleanequals(Object obj)booleanisEmpty()static <T> Set<T>of(T... elements)Creates a new immutable set that consists of given elements.booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)Spliterator<T>spliterator()-
Methods inherited from class java.util.AbstractSet
hashCode
-
Methods inherited from class java.util.AbstractCollection
contains, iterator, size, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
-
-
-
Method Detail
-
copyOf
public static <T> Set<T> copyOf(Collection<? extends T> collection)
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
@SafeVarargs public static <T> Set<T> of(T... elements)
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
public static <T> ImmutableSet.Builder<T> builder()
Creates a new empty builder for building immutable sets.- Returns:
- a new empty builder
-
add
public boolean add(T e)
- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceSet<T>- Overrides:
addin classAbstractCollection<T>
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<T>- Specified by:
removein interfaceSet<T>- Overrides:
removein classAbstractCollection<T>
-
addAll
public boolean addAll(Collection<? extends T> c)
- Specified by:
addAllin interfaceCollection<T>- Specified by:
addAllin interfaceSet<T>- Overrides:
addAllin classAbstractCollection<T>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<T>- Specified by:
retainAllin interfaceSet<T>- Overrides:
retainAllin classAbstractCollection<T>
-
removeAll
public boolean removeAll(Collection<?> c)
- 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
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceSet<T>- Overrides:
containsAllin classAbstractCollection<T>
-
equals
public boolean equals(Object obj)
- Specified by:
equalsin interfaceCollection<T>- Specified by:
equalsin interfaceSet<T>- Overrides:
equalsin classAbstractSet<T>
-
spliterator
public Spliterator<T> spliterator()
- Specified by:
spliteratorin interfaceCollection<T>- Specified by:
spliteratorin interfaceIterable<T>- Specified by:
spliteratorin interfaceSet<T>
-
-