Class BLCArrayUtils
java.lang.Object
org.broadleafcommerce.common.util.BLCArrayUtils
Convenience methods for interacting with arrays
- Author:
- Andre Azzolini (apazzolini)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ArrayList<T>
asList
(T[] array) Given an input array, will return an ArrayList representation of the array.static <T,
O> ArrayList<T> collect
(Object[] array, TypedTransformer<T> transformer) Similar to the CollectionUtils collect except that it works on an array instead of a Java Collectionstatic <T,
O> HashSet<T> collectSet
(Object[] array, TypedTransformer<T> transformer) The same ascollect(Object[], TypedTransformer)
but returns a set.static <T> boolean
contains
(T[] array, TypedPredicate<T> predicate) Given an array and a typed predicate, determines if the array has an object that matches the condition of the predicate.
-
Constructor Details
-
BLCArrayUtils
public BLCArrayUtils()
-
-
Method Details
-
contains
Given an array and a typed predicate, determines if the array has an object that matches the condition of the predicate. The predicate should evaluate to true when a match occurs.- Parameters:
array
-predicate
-- Returns:
- whether or not the array contains an element that matches the predicate
-
asList
Given an input array, will return an ArrayList representation of the array.- Parameters:
array
-- Returns:
- the ArrayList corresponding to the input array. If the input is null, this also returns null. If it is empty then this will return an empty list
-
collect
Similar to the CollectionUtils collect except that it works on an array instead of a Java Collection- Parameters:
array
-transformer
-- Returns:
- the transformed collection
-
collectSet
The same ascollect(Object[], TypedTransformer)
but returns a set.- Parameters:
array
-transformer
-- Returns:
- the transformed set
-