T
- contained in the created collections.@NotThreadSafe public final class CollectionBuilder<T> extends Object
Set
and List
) instances or
enclosed iterables
.
The default methods asList()
and asSet()
and asSortedSet()
create immutable collections.
Modifier and Type | Method and Description |
---|---|
CollectionBuilder<T> |
add(T element) |
CollectionBuilder<T> |
addAll(Collection<? extends T> elements) |
<E extends T> |
addAll(E... elements) |
CollectionBuilder<T> |
addAll(Enumeration<? extends T> elements) |
List<T> |
asArrayList() |
Collection<T> |
asCollection() |
EnclosedIterable<T> |
asEnclosedIterable() |
Set<T> |
asHashSet() |
Set<T> |
asImmutableListOrderedSet() |
List<T> |
asLinkedList() |
List<T> |
asList() |
Set<T> |
asListOrderedSet() |
Collection<T> |
asMutableCollection() |
List<T> |
asMutableList() |
Set<T> |
asMutableSet() |
SortedSet<T> |
asMutableSortedSet() |
Set<T> |
asSet() |
SortedSet<T> |
asSortedSet()
Return a
SortedSet of the elements of this builder in their natural order. |
SortedSet<T> |
asSortedSet(Comparator<? super T> comparator) |
SortedSet<T> |
asTreeSet() |
static <T> List<T> |
list(T... elements) |
static <T> CollectionBuilder<T> |
newBuilder() |
static <T> CollectionBuilder<T> |
newBuilder(T... elements) |
public static <T> CollectionBuilder<T> newBuilder()
public static <T> CollectionBuilder<T> newBuilder(T... elements)
public static <T> List<T> list(T... elements)
public CollectionBuilder<T> add(T element)
public <E extends T> CollectionBuilder<T> addAll(E... elements)
public CollectionBuilder<T> addAll(Collection<? extends T> elements)
public CollectionBuilder<T> addAll(Enumeration<? extends T> elements)
public Collection<T> asCollection()
public Collection<T> asMutableCollection()
public SortedSet<T> asSortedSet()
SortedSet
of the elements of this builder in their natural order.
Note, will throw an exception if the elements are not comparable.ClassCastException
- if the elements do not implement Comparable
.public SortedSet<T> asSortedSet(Comparator<? super T> comparator)
public EnclosedIterable<T> asEnclosedIterable()
Copyright © 2002-2015 Atlassian. All Rights Reserved.