Package org.hisp.dhis.util
Class CollectionUtils
java.lang.Object
org.hisp.dhis.util.CollectionUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>asList(T[] array) Converts the given array to anArrayList.static <T> TfirstMatch(Collection<T> collection, Predicate<T> predicate) Returns the first matching item in the given collection based on the given predicate.static <T> TReturns the item at the given index in the given list.static <T> List<T>list(Collection<T> collection, Predicate<T> predicate) Returns a new mutable list of the items in the given collection which match the given predicate.static <T> List<T>list(T... items) Returns an immutable list containing the given items.static <T> List<T>mutableList(T... items) Returns a mutable list containing the given items.static <T> Set<T>mutableSet(T... items) Returns a mutable set containing the given items.static <T> booleannotEmpty(Collection<T> collection) Indicates if the given collection is not null and not empty.static <T> Set<T>set(T... items) Returns an immutable set containing the given items.
-
Constructor Details
-
CollectionUtils
public CollectionUtils()
-
-
Method Details
-
set
Returns an immutable set containing the given items. Accepts null items.- Type Parameters:
T- type.- Parameters:
items- the items.- Returns:
- an immutable set.
-
mutableSet
Returns a mutable set containing the given items. Accepts null items.- Type Parameters:
T- type.- Parameters:
items- the items.- Returns:
- an immutable set.
-
list
Returns an immutable list containing the given items. Accepts null items.- Type Parameters:
T- type.- Parameters:
items- the items.- Returns:
- an immutable list.
-
mutableList
Returns a mutable list containing the given items. Accepts null items.- Type Parameters:
T- type.- Parameters:
items- the items.- Returns:
- an immutable list.
-
asList
Converts the given array to anArrayList.- Type Parameters:
T- type.- Parameters:
array- the array.- Returns:
- a list.
-
firstMatch
Returns the first matching item in the given collection based on the given predicate. Returns null if no match is found.- Type Parameters:
T- type.- Parameters:
collection- the collection.predicate- the predicate.- Returns:
- the first matching item, or null if no match is found.
-
list
Returns a new mutable list of the items in the given collection which match the given predicate.- Type Parameters:
T- type.- Parameters:
collection- the collection.predicate- the predicate.- Returns:
- a new mutable list.
-
notEmpty
Indicates if the given collection is not null and not empty.- Type Parameters:
T- type.- Parameters:
collection- the collection.- Returns:
- true if the given collection is not null and not empty.
-
get
Returns the item at the given index in the given list. Returns null if the index is out of bounds.- Type Parameters:
T-- Parameters:
list- the list.index- the index.- Returns:
- an item or null.
-