org.broadleafcommerce.common.util
Class BLCArrayUtils

java.lang.Object
  extended by org.broadleafcommerce.common.util.BLCArrayUtils

public class BLCArrayUtils
extends Object

Convenience methods for interacting with arrays

Author:
Andre Azzolini (apazzolini)

Constructor Summary
BLCArrayUtils()
           
 
Method Summary
static
<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 Collection
static
<T,O> HashSet<T>
collectSet(Object[] array, TypedTransformer<T> transformer)
          The same as collect(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BLCArrayUtils

public BLCArrayUtils()
Method Detail

contains

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

public static <T> ArrayList<T> asList(T[] array)
Given an input array, will return an ArrayList representation of the array.

Parameters:
array -
Returns:
the ArrayList corresponding to the input array

collect

public 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 Collection

Parameters:
array -
transformer -
Returns:
the transformed collection

collectSet

public static <T,O> HashSet<T> collectSet(Object[] array,
                                          TypedTransformer<T> transformer)
The same as collect(Object[], TypedTransformer) but returns a set.

Parameters:
array -
transformer -
Returns:
the transformed set


Copyright © 2013. All Rights Reserved.