Class BatchUtils

java.lang.Object
org.nuxeo.common.utils.BatchUtils

public class BatchUtils extends Object
Batching utilities.
Since:
10.10
  • Method Details

    • groupByDerived

      public static <T, U> List<org.apache.commons.lang3.tuple.Pair<U,List<T>>> groupByDerived(List<T> values, Function<T,U> deriver, BiPredicate<U,U> comparator)
      Takes the input values and batches them together in groups. All values in a given group have the same derived value. The derived value is computed using the deriver function. Two derived values are compared for equality using the comparator.
      Type Parameters:
      T - the type of the values
      U - the type of the derived values
      Parameters:
      values - the input values
      deriver - the function to compute a derived value
      comparator - the equality test for derived values
      Returns:
      a list of pairs with a derived values and the corresponding batch
      Since:
      10.10