com.atlassian.jira.util.collect
Class CollectionBuilder<T>

java.lang.Object
  extended by 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.


Method Summary
 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()
          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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

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-2014 Atlassian. All Rights Reserved.