com.atlassian.jira.util.collect
Class CollectionBuilder<T>
java.lang.Object
com.atlassian.jira.util.collect.CollectionBuilder<T>
- Type Parameters:
T
- contained in the created collections.
@NotThreadSafe
public final class CollectionBuilder<T>
- extends Object
Convenience class for creating collections (Set
and List
) instances or
enclosed iterables
.
The default methods asList()
and asSet()
and asSortedSet()
create immutable collections.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
newBuilder
public static <T> CollectionBuilder<T> newBuilder()
newBuilder
public static <T> CollectionBuilder<T> newBuilder(T... elements)
list
public static <T> List<T> list(T... elements)
add
public CollectionBuilder<T> add(T element)
addAll
public <E extends T> CollectionBuilder<T> addAll(E... elements)
addAll
public CollectionBuilder<T> addAll(Collection<? extends T> elements)
addAll
public CollectionBuilder<T> addAll(Enumeration<? extends T> elements)
asCollection
public Collection<T> asCollection()
asMutableCollection
public Collection<T> asMutableCollection()
asArrayList
public List<T> asArrayList()
asLinkedList
public List<T> asLinkedList()
asList
public List<T> asList()
asMutableList
public List<T> asMutableList()
asHashSet
public Set<T> asHashSet()
asListOrderedSet
public Set<T> asListOrderedSet()
asImmutableListOrderedSet
public Set<T> asImmutableListOrderedSet()
asSet
public Set<T> asSet()
asMutableSet
public Set<T> asMutableSet()
asTreeSet
public SortedSet<T> asTreeSet()
asSortedSet
public SortedSet<T> asSortedSet()
- Return a
SortedSet
of the elements of this builder in their natural order.
Note, will throw an exception if the elements are not comparable.
- Returns:
- an immutable sorted set.
- Throws:
ClassCastException
- if the elements do not implement Comparable
.
asSortedSet
public SortedSet<T> asSortedSet(Comparator<? super T> comparator)
asMutableSortedSet
public SortedSet<T> asMutableSortedSet()
asEnclosedIterable
public EnclosedIterable<T> asEnclosedIterable()
Copyright © 2002-2011 Atlassian. All Rights Reserved.