Top Description Constructors Methods
org.eclipse.persistence.jpa.jpql.utility

public final Class CollectionTools

extends Object
Class Inheritance
Imports
java.lang.reflect.Array, java.util.ArrayList, .Collection, .Iterator, .List

This 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.

Author
Pascal Filion
Since
2.4
Version
2.5

Constructor Summary

AccessConstructor and Description
private
CollectionTools()

Creates a new CollectionTools.

Method Summary

Modifier and TypeMethod and Description
public static <
The type of the collection
T extends Collection<E>
,
The type of the element
E
>
T

Returns:

The given Collection
addAll
(T
The Collection that will receive the items returned by the Iterator
collection
,
E[]
The array to add to the given Collection
array
)

Adds to the given Collection the items contained in the array.

public static <
The type of the collection
T extends Collection<E>
,
The type of the element
E
>
T

Returns:

The given Collection
addAll
(T
The Collection that will receive the items returned by the Iterator
collection
,
Iterable<? extends E>
The Iterable to add to the given Collection
iterable
)

Adds to the given Collection the items contained in the Iterable.

public static <
The type of the collection
T extends Collection<E>
,
The type of the element
E
>
T

Returns:

The given Collection
addAll
(T
The Collection that will receive the items returned by the Iterator
collection
,
Iterator<? extends E>
The Iterator that will return the items to add to the Collection
iterator
)

Adds to the given Collection the items returned by the given Iterator.

public static <T> T[]

Returns:

A new array filled with the items returned by the given iterator
array
(Class<T>
The type of the array
componentType
,
Iterable<? extends T>
The Iterable that will iterate over the collection of items to add into the new array in the same order they are returned
iterable
)

Creates a new array and adds the items returned by the given Iterable.

public static <T> T[]

Returns:

A new array filled with the items returned by the given iterator
array
(Class<T>
The type of the array
componentType
,
Iterator<? extends T>
The Iterator that will iterate over the collection of items to add into the new array in the same order they are returned
iterator
)

Creates a new array and adds the items returned by the given Iterator.

public static <E> List<E>

Returns:

An instance of a List containing the elements of the given array
list
(E...
The array to convert into a List
array
)

Returns a list corresponding to the specified array.

public static <T> List<T>

Returns:

A new List
list
(Iterator<? extends T>
The ListIterator to iterate over items to add into a list in the same order they are returned
iterator
)

Creates a new List and adds the items returned by the given ListIterator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CollectionToolsback to summary
private CollectionTools()

Creates a new CollectionTools.

Method Detail

addAllback to summary
public static <T extends Collection<E>, E> T addAll(T collection, E[] array)

Adds to the given Collection the items contained in the array.

Parameters
<T>
The type of the collection
<E>
The type of the element
collection:T

The Collection that will receive the items returned by the Iterator

array:E[]

The array to add to the given Collection

Returns:T

The given Collection

Since
2.4.1
addAllback to summary
public static <T extends Collection<E>, E> T addAll(T collection, Iterable<? extends E> iterable)

Adds to the given Collection the items contained in the Iterable.

Parameters
<T>
The type of the collection
<E>
The type of the element
collection:T

The Collection that will receive the items returned by the Iterator

iterable:Iterable<? extends E>

The Iterable to add to the given Collection

Returns:T

The given Collection

Since
2.5
addAllback to summary
public static <T extends Collection<E>, E> T addAll(T collection, Iterator<? extends E> iterator)

Adds to the given Collection the items returned by the given Iterator.

Parameters
<T>
The type of the collection
<E>
The type of the element
collection:T

The Collection that will receive the items returned by the Iterator

iterator:Iterator<? extends E>

The Iterator that will return the items to add to the Collection

Returns:T

The given Collection

arrayback to summary
public static <T> T[] array(Class<T> componentType, Iterable<? extends T> iterable)

Creates a new array and adds the items returned by the given Iterable.

Parameters
componentType:Class<T>

The type of the array

iterable:Iterable<? extends T>

The Iterable that will iterate over the collection of items to add into the new array in the same order they are returned

Returns:T[]

A new array filled with the items returned by the given iterator

Since
2.5
arrayback to summary
public static <T> T[] array(Class<T> componentType, Iterator<? extends T> iterator)

Creates a new array and adds the items returned by the given Iterator.

Parameters
componentType:Class<T>

The type of the array

iterator:Iterator<? extends T>

The Iterator that will iterate over the collection of items to add into the new array in the same order they are returned

Returns:T[]

A new array filled with the items returned by the given iterator

Annotations
@SuppressWarnings:unchecked
listback to summary
public static <E> List<E> list(E... array)

Returns a list corresponding to the specified array. Unlike java.util.Arrays#asList(Object[]), the list is modifiable and is not backed by the array.

Parameters
array:E[]

The array to convert into a List

Returns:List<E>

An instance of a List containing the elements of the given array

Annotations
@SafeVarargs
Since
2.5
listback to summary
public static <T> List<T> list(Iterator<? extends T> iterator)

Creates a new List and adds the items returned by the given ListIterator.

Parameters
iterator:Iterator<? extends T>

The ListIterator to iterate over items to add into a list in the same order they are returned

Returns:List<T>

A new List