Class ListUtils
java.lang.Object
no.mnemonic.commons.utilities.collections.ListUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>
Adds an element to a list unless the element is null.static <T> List<T>
concatenate
(List<T>... lists) Concatenates multiple lists into one new list.static <T> List<T>
list
(Collection<T> collection) Creates a list from another collection.static <T,
V> List<V> list
(Collection<T> collection, Function<T, V> mapping) Creates a list from another collection using a mapping function converting all values.static <T,
V> List<V> Creates a list from its arguments using a mapping function converting all values.static <T> List<T>
Creates a list from an iterator.static <T,
V> List<V> Creates a list from an iterator using a mapping function converting all values.static <T> List<T>
list
(T... values) Creates a list from its arguments.
-
Method Details
-
list
Creates a list from its arguments.- Type Parameters:
T
- Type of value parameters.- Parameters:
values
- Values to be added to the list.- Returns:
- A list containing all values.
-
list
Creates a list from an iterator.- Type Parameters:
T
- Type of iterator values.- Parameters:
iterator
- An iterator which values are added to the list.- Returns:
- A list containing all values supplied by the given iterator.
-
list
Creates a list from another collection.- Type Parameters:
T
- Type of collection values.- Parameters:
collection
- A collection which values are added to the list.- Returns:
- A list containing all values contained in the given collection, omitting null elements.
-
list
Creates a list from its arguments using a mapping function converting all values.- Type Parameters:
T
- Type of value parameters before conversion.V
- Type of values in the returned list after conversion.- Parameters:
mapping
- A mapping function applied to all values.values
- Values to be added to the list.- Returns:
- A list containing all values converted using the mapping function.
-
list
Creates a list from an iterator using a mapping function converting all values.- Type Parameters:
T
- Type of iterator values before conversion.V
- Type of values in the returned list after conversion.- Parameters:
iterator
- An iterator which values are added to the list.mapping
- A mapping function applied to all values.- Returns:
- A list containing all values supplied by the given iterator and converted using the mapping function.
-
list
Creates a list from another collection using a mapping function converting all values.- Type Parameters:
T
- Type of collection values before conversion.V
- Type of values in the returned list after conversion.- Parameters:
collection
- A collection which values are added to the list.mapping
- A mapping function applied to all values.- Returns:
- A list containing all values contained in the given collection and converted using the mapping function, omitting null elements.
-
addToList
Adds an element to a list unless the element is null.A new list is created if the provided list is null.
- Type Parameters:
T
- Type of elements.- Parameters:
list
- List to which the element will be added.element
- Element to add.- Returns:
- List including added element.
-
concatenate
Concatenates multiple lists into one new list.- Type Parameters:
T
- Type of list values.- Parameters:
lists
- Multiple lists which will be concatenated.- Returns:
- A list containing all values from the given lists.
-