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 java.lang.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(java.util.Collection<? extends T> elements)
           
<E extends T>
CollectionBuilder<T>
addAll(E... elements)
           
 CollectionBuilder<T> addAll(java.util.Enumeration<? extends T> elements)
           
 java.util.List<T> asArrayList()
           
 java.util.Collection<T> asCollection()
           
 EnclosedIterable<T> asEnclosedIterable()
           
 java.util.Set<T> asHashSet()
           
 java.util.Set<T> asImmutableListOrderedSet()
           
 java.util.List<T> asLinkedList()
           
 java.util.List<T> asList()
           
 java.util.Set<T> asListOrderedSet()
           
 java.util.Collection<T> asMutableCollection()
           
 java.util.List<T> asMutableList()
           
 java.util.Set<T> asMutableSet()
           
 java.util.SortedSet<T> asMutableSortedSet()
           
 java.util.Set<T> asSet()
           
 java.util.SortedSet<T> asSortedSet()
          Return a SortedSet of the elements of this builder in their natural order.
 java.util.SortedSet<T> asSortedSet(java.util.Comparator<? super T> comparator)
           
 java.util.SortedSet<T> asTreeSet()
           
static
<T> java.util.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> java.util.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(java.util.Collection<? extends T> elements)

addAll

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

asCollection

public java.util.Collection<T> asCollection()

asMutableCollection

public java.util.Collection<T> asMutableCollection()

asArrayList

public java.util.List<T> asArrayList()

asLinkedList

public java.util.List<T> asLinkedList()

asList

public java.util.List<T> asList()

asMutableList

public java.util.List<T> asMutableList()

asHashSet

public java.util.Set<T> asHashSet()

asListOrderedSet

public java.util.Set<T> asListOrderedSet()

asImmutableListOrderedSet

public java.util.Set<T> asImmutableListOrderedSet()

asSet

public java.util.Set<T> asSet()

asMutableSet

public java.util.Set<T> asMutableSet()

asTreeSet

public java.util.SortedSet<T> asTreeSet()

asSortedSet

public java.util.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:
java.lang.ClassCastException - if the elements do not implement Comparable.

asSortedSet

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

asMutableSortedSet

public java.util.SortedSet<T> asMutableSortedSet()

asEnclosedIterable

public EnclosedIterable<T> asEnclosedIterable()


Copyright © 2002-2010 Atlassian. All Rights Reserved.