public final class CollectionTools
extends java.lang.Object
Provisional API: This interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.
Modifier and Type | Method and Description |
---|---|
static <T extends java.util.Collection<E>,E> |
addAll(T collection,
E[] array)
Adds to the given
Collection the items contained in the array. |
static <T extends java.util.Collection<E>,E> |
addAll(T collection,
java.lang.Iterable<? extends E> iterable)
Adds to the given
Collection the items contained in the Iterable . |
static <T extends java.util.Collection<E>,E> |
addAll(T collection,
java.util.Iterator<? extends E> iterator)
Adds to the given
Collection the items returned by the given Iterator . |
static <T> T[] |
array(java.lang.Class<T> componentType,
java.lang.Iterable<? extends T> iterable)
Creates a new array and adds the items returned by the given
Iterable . |
static <T> T[] |
array(java.lang.Class<T> componentType,
java.util.Iterator<? extends T> iterator)
Creates a new array and adds the items returned by the given
Iterator . |
static <E> java.util.List<E> |
list(E... array)
Returns a list corresponding to the specified array.
|
static <T> java.util.List<T> |
list(java.util.Iterator<? extends T> iterator)
Creates a new
List and adds the items returned by the given ListIterator . |
public static <T extends java.util.Collection<E>,E> T addAll(T collection, E[] array)
Collection
the items contained in the array.T
- The type of the collectionE
- The type of the elementcollection
- The Collection
that will receive the items returned by the Iterator
array
- The array to add to the given Collection
Collection
public static <T extends java.util.Collection<E>,E> T addAll(T collection, java.lang.Iterable<? extends E> iterable)
Collection
the items contained in the Iterable
.T
- The type of the collectionE
- The type of the elementcollection
- The Collection
that will receive the items returned by the Iterator
iterable
- The Iterable
to add to the given Collection
Collection
public static <T extends java.util.Collection<E>,E> T addAll(T collection, java.util.Iterator<? extends E> iterator)
Collection
the items returned by the given Iterator
.T
- The type of the collectionE
- The type of the elementcollection
- The Collection
that will receive the items returned by the Iterator
iterator
- The Iterator
that will return the items to add to the Collection
Collection
public static <T> T[] array(java.lang.Class<T> componentType, java.lang.Iterable<? extends T> iterable)
Iterable
.componentType
- The type of the arrayiterable
- The Iterable
that will iterate over the collection of items to add
into the new array in the same order they are returnedpublic static <T> T[] array(java.lang.Class<T> componentType, java.util.Iterator<? extends T> iterator)
Iterator
.componentType
- The type of the arrayiterator
- The Iterator
that will iterate over the collection of items to add
into the new array in the same order they are returnedpublic static <E> java.util.List<E> list(E... array)
Arrays.asList(Object[])
,
the list is modifiable and is not backed by the array.E
- array
- The array to convert into a List
List
containing the elements of the given arraypublic static <T> java.util.List<T> list(java.util.Iterator<? extends T> iterator)
List
and adds the items returned by the given ListIterator
.iterator
- The ListIterator
to iterate over items to add
into a list in the same order they are returnedList