Class CollectionTools
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.utility.CollectionTools
-
public final class CollectionTools extends java.lang.ObjectThis utility class provides utility methods related to collections, iterators and arrays.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.
- Version:
- 2.5
- Author:
- Pascal Filion
- Since:
- 2.4
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends java.util.Collection<E>,E>
TaddAll(T collection, E[] array)Adds to the givenCollectionthe items contained in the array.static <T extends java.util.Collection<E>,E>
TaddAll(T collection, java.lang.Iterable<? extends E> iterable)Adds to the givenCollectionthe items contained in theIterable.static <T extends java.util.Collection<E>,E>
TaddAll(T collection, java.util.Iterator<? extends E> iterator)Adds to the givenCollectionthe items returned by the givenIterator.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 givenIterable.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 givenIterator.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 newListand adds the items returned by the givenListIterator.
-
-
-
Method Detail
-
addAll
public static <T extends java.util.Collection<E>,E> T addAll(T collection, E[] array)Adds to the givenCollectionthe items contained in the array.- Type Parameters:
T- The type of the collectionE- The type of the element- Parameters:
collection- TheCollectionthat will receive the items returned by theIteratorarray- The array to add to the givenCollection- Returns:
- The given
Collection - Since:
- 2.4.1
-
addAll
public static <T extends java.util.Collection<E>,E> T addAll(T collection, java.lang.Iterable<? extends E> iterable)Adds to the givenCollectionthe items contained in theIterable.- Type Parameters:
T- The type of the collectionE- The type of the element- Parameters:
collection- TheCollectionthat will receive the items returned by theIteratoriterable- TheIterableto add to the givenCollection- Returns:
- The given
Collection - Since:
- 2.5
-
addAll
public static <T extends java.util.Collection<E>,E> T addAll(T collection, java.util.Iterator<? extends E> iterator)Adds to the givenCollectionthe items returned by the givenIterator.- Type Parameters:
T- The type of the collectionE- The type of the element- Parameters:
collection- TheCollectionthat will receive the items returned by theIteratoriterator- TheIteratorthat will return the items to add to theCollection- Returns:
- The given
Collection
-
array
public 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 givenIterable.- Parameters:
componentType- The type of the arrayiterable- TheIterablethat will iterate over the collection of items to add into the new array in the same order they are returned- Returns:
- A new array filled with the items returned by the given iterator
- Since:
- 2.5
-
array
public 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 givenIterator.- Parameters:
componentType- The type of the arrayiterator- TheIteratorthat will iterate over the collection of items to add into the new array in the same order they are returned- Returns:
- A new array filled with the items returned by the given iterator
-
list
public static <E> java.util.List<E> list(E... array)
Returns a list corresponding to the specified array. UnlikeArrays.asList(Object[]), the list is modifiable and is not backed by the array.- Type Parameters:
E-- Parameters:
array- The array to convert into aList- Returns:
- An instance of a
Listcontaining the elements of the given array - Since:
- 2.5
-
list
public static <T> java.util.List<T> list(java.util.Iterator<? extends T> iterator)
Creates a newListand adds the items returned by the givenListIterator.- Parameters:
iterator- TheListIteratorto iterate over items to add into a list in the same order they are returned- Returns:
- A new
List
-
-