Class BLCArrayUtils

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

public class BLCArrayUtils extends Object
Convenience methods for interacting with arrays
Author:
Andre Azzolini (apazzolini)
  • Constructor Details

    • BLCArrayUtils

      public BLCArrayUtils()
  • Method Details

    • 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. If the input is null, this also returns null. If it is empty then this will return an empty list
    • 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