E - the type of the List's elements.public static final class ImmutableList.Builder<E> extends Object
ImmutableList builder. Not thread-safe.| Constructor and Description |
|---|
ImmutableList.Builder() |
| Modifier and Type | Method and Description |
|---|---|
ImmutableList.Builder<E> |
add(E... values)
Adds the given values to the
List being built. |
ImmutableList.Builder<E> |
add(Iterable<? extends E> values)
Adds all the values contained in the given
Iterable
to the List being built. |
ImmutableList.Builder<E> |
add(Iterator<? extends E> values)
Adds all the values contained in the given
Iterator
to the List being built. |
List<E> |
build()
Finalizes the creation of the
ImmutableList. |
ImmutableList.Builder<E> |
reverse()
Reverses the order of the elements currently in the
List being built. |
ImmutableList.Builder<E> |
rotate(int n)
Rotates the elements currently in the
List being
built by the specified distance. |
ImmutableList.Builder<E> |
shuffle()
Randomly permutes the elements currently in the
List
being built using a default source of randomness. |
ImmutableList.Builder<E> |
shuffle(Random random)
Randomly permutes the elements currently in the
List
being built using the specified source of randomness. |
ImmutableList.Builder<E> |
sort()
Sorts the elements currently in the
List being built
into ascending order, according to the natural ordering of
its elements (all elements in this builder must implement the
Comparable interface). |
ImmutableList.Builder<E> |
sort(Comparator<? super E> c)
Sorts the elements currently in the
List being built
into ascending order, according to the order induced by the
given Comparator. |
public ImmutableList.Builder<E> add(E... values)
List being built.values - the values to add.NullPointerException - if values is null.public ImmutableList.Builder<E> add(Iterable<? extends E> values)
Iterable
to the List being built.values - the values to add.NullPointerException - if values is null.public ImmutableList.Builder<E> add(Iterator<? extends E> values)
Iterator
to the List being built.values - the values to add.NullPointerException - if values is null.public ImmutableList.Builder<E> sort()
List being built
into ascending order, according to the natural ordering of
its elements (all elements in this builder must implement the
Comparable interface).ClassCastException - if this builder contains elements
that are not mutually comparable.IllegalArgumentException - if the natural ordering of
the elements in this builder is found to violate the
Comparable contract.public ImmutableList.Builder<E> sort(Comparator<? super E> c)
List being built
into ascending order, according to the order induced by the
given Comparator.c - the Comparator to use.ClassCastException - if this builder contains elements
that are not mutually comparable using the specified
Comparator.IllegalArgumentException - if the comparator is found
to violate the Comparator contract.public ImmutableList.Builder<E> reverse()
List being built.public ImmutableList.Builder<E> rotate(int n)
List being
built by the specified distance.n - the distance to rotate.public ImmutableList.Builder<E> shuffle()
List
being built using a default source of randomness. All
permutations occur with approximately equal likelihood.public ImmutableList.Builder<E> shuffle(Random random)
List
being built using the specified source of randomness. All
permutations occur with equal likelihood assuming that the
source of randomness is fair.random - the source of randomness to use.NullPointerException - if random is null.Copyright © 2012–2015. All rights reserved.