Class CollectionUtils
java.lang.Object
de.iip_ecosphere.platform.support.CollectionUtils
Some useful additional collection methods.
- Author:
- Holger Eichelberger, SSE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T> Turns givenelementstolist.static <T> Set<T> Turns givenelementstoset.static voidReverses the order of the given array.static <T> List<T> Turns the elements in the iterable into a list.static <T> List<T> toList(Enumeration<T> en) Turns the elements in the enumeration into a list.static <T> List<T> Turns the elements in the iterator into a list.static <T> List<T> toList(T... elements) Turns givenelementsinto a list.static <T> Set<T> Turns the elements in the iterable into a set.static <T> Set<T> toSet(Enumeration<T> en) Turns the elements in the enumeration into a set.static <T> Set<T> Turns the elements in the iterator into a set.static <T> Set<T> toSet(T... elements) Turns givenelementsinto a list.static StringtoString(Collection<?> collection, String leadIn, String leadOut, String separator) Turns a collection into a string with configurable lead-in, separator and lead-out.static StringtoStringSpaceSeparated(Collection<?> collection) Turns a collection into a string with no lead-in, one space as separator and no lead-out.
-
Constructor Details
-
CollectionUtils
public CollectionUtils()
-
-
Method Details
-
toList
Turns givenelementsinto a list.- Type Parameters:
T- the element type- Parameters:
elements- the elements- Returns:
- the list containing all
elements
-
toSet
Turns givenelementsinto a list.- Type Parameters:
T- the element type- Parameters:
elements- the elements- Returns:
- the list containing all
elements
-
addAll
Turns givenelementstolist.- Type Parameters:
T- the element type- Parameters:
list- the list to be modified as a side effectelements- the elements- Returns:
- the list with all
elementsadded
-
addAll
Turns givenelementstoset.- Type Parameters:
T- the element type- Parameters:
set- the set to be modified as a side effectelements- the elements- Returns:
- the set with all
elementsadded
-
toList
Turns the elements in the iterable into a list.- Type Parameters:
T- the element type- Parameters:
iterable- the iterable- Returns:
- the list with all elements in
iterable
-
toList
Turns the elements in the iterator into a list.- Type Parameters:
T- the element type- Parameters:
iterator- the iterator- Returns:
- the list with all elements in
iterator
-
toList
Turns the elements in the enumeration into a list.- Type Parameters:
T- the element type- Parameters:
en- the enumeration- Returns:
- the list with all elements in
en
-
toSet
Turns the elements in the iterable into a set.- Type Parameters:
T- the element type- Parameters:
iterable- the iterable- Returns:
- the set with all elements in
iterable
-
toSet
Turns the elements in the iterator into a set.- Type Parameters:
T- the element type- Parameters:
iterator- the iterator- Returns:
- the set with all elements in
iterator
-
toSet
Turns the elements in the enumeration into a set.- Type Parameters:
T- the element type- Parameters:
en- the enumeration- Returns:
- the set with all elements in
en
-
toString
public static String toString(Collection<?> collection, String leadIn, String leadOut, String separator) Turns a collection into a string with configurable lead-in, separator and lead-out.- Parameters:
collection- the collectionleadIn- the lead-inleadOut- the lead-outseparator- the separator- Returns:
- the string representation
-
toStringSpaceSeparated
Turns a collection into a string with no lead-in, one space as separator and no lead-out.- Parameters:
collection- the collection- Returns:
- the string representation
-
reverse
Reverses the order of the given array. There is no special handling for multi-dimensional arrays. This method does nothing for a null input array.- Parameters:
array- the array to reverse, may be null
-