@NotThreadSafe public final class

CollectionBuilder

extends Object
java.lang.Object
   ↳ com.atlassian.jira.util.collect.CollectionBuilder<T>

Class Overview

Convenience class for creating collections (Set and List) instances or enclosed iterables.

The default methods asList() and asSet() and asSortedSet() create immutable collections.

Summary

Public Methods
CollectionBuilder<T> add(T element)
CollectionBuilder<T> addAll(Collection<? extends T> elements)
<E extends T> CollectionBuilder<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(Comparator<? super T> comparator)
SortedSet<T> asSortedSet()
Return a SortedSet of the elements of this builder in their natural order.
SortedSet<T> asTreeSet()
static <T> List<T> list(T... elements)
static <T> CollectionBuilder<T> newBuilder()
static <T> CollectionBuilder<T> newBuilder(T... elements)
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public CollectionBuilder<T> add (T element)

public CollectionBuilder<T> addAll (Collection<? extends T> elements)

public CollectionBuilder<T> addAll (E... elements)

public CollectionBuilder<T> addAll (Enumeration<? extends T> elements)

public List<T> asArrayList ()

public Collection<T> asCollection ()

public EnclosedIterable<T> asEnclosedIterable ()

public Set<T> asHashSet ()

public Set<T> asImmutableListOrderedSet ()

public List<T> asLinkedList ()

public List<T> asList ()

public Set<T> asListOrderedSet ()

public Collection<T> asMutableCollection ()

public List<T> asMutableList ()

public Set<T> asMutableSet ()

public SortedSet<T> asMutableSortedSet ()

public Set<T> asSet ()

public SortedSet<T> asSortedSet (Comparator<? super T> comparator)

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.

public SortedSet<T> asTreeSet ()

public static List<T> list (T... elements)

public static CollectionBuilder<T> newBuilder ()

public static CollectionBuilder<T> newBuilder (T... elements)