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 interface
ImmutableSet.Builder<T>
Builder for building immutable sets.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T e)
boolean
addAll(Collection<? extends T> c)
static <T> ImmutableSet.Builder<T>
builder()
Creates a new empty builder for building immutable sets.void
clear()
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.boolean
containsAll(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.boolean
equals(Object obj)
boolean
isEmpty()
static <T> Set<T>
of(T... elements)
Creates a new immutable set that consists of given elements.boolean
remove(Object o)
boolean
removeAll(Collection<?> c)
boolean
retainAll(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:
add
in interfaceCollection<T>
- Specified by:
add
in interfaceSet<T>
- Overrides:
add
in classAbstractCollection<T>
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<T>
- Specified by:
remove
in interfaceSet<T>
- Overrides:
remove
in classAbstractCollection<T>
-
addAll
public boolean addAll(Collection<? extends T> c)
- Specified by:
addAll
in interfaceCollection<T>
- Specified by:
addAll
in interfaceSet<T>
- Overrides:
addAll
in classAbstractCollection<T>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll
in interfaceCollection<T>
- Specified by:
retainAll
in interfaceSet<T>
- Overrides:
retainAll
in classAbstractCollection<T>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll
in interfaceCollection<T>
- Specified by:
removeAll
in interfaceSet<T>
- Overrides:
removeAll
in classAbstractSet<T>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<T>
- Specified by:
clear
in interfaceSet<T>
- Overrides:
clear
in classAbstractCollection<T>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<T>
- Specified by:
isEmpty
in interfaceSet<T>
- Overrides:
isEmpty
in classAbstractCollection<T>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<T>
- Specified by:
containsAll
in interfaceSet<T>
- Overrides:
containsAll
in classAbstractCollection<T>
-
equals
public boolean equals(Object obj)
- Specified by:
equals
in interfaceCollection<T>
- Specified by:
equals
in interfaceSet<T>
- Overrides:
equals
in classAbstractSet<T>
-
spliterator
public Spliterator<T> spliterator()
- Specified by:
spliterator
in interfaceCollection<T>
- Specified by:
spliterator
in interfaceIterable<T>
- Specified by:
spliterator
in interfaceSet<T>
-
-