Package org.nuxeo.common.utils
Class BatchUtils
java.lang.Object
org.nuxeo.common.utils.BatchUtils
Batching utilities.
- Since:
- 10.10
-
Method Summary
Modifier and TypeMethodDescriptiongroupByDerived
(List<T> values, Function<T, U> deriver, BiPredicate<U, U> comparator) Takes the inputvalues
and batches them together in groups.
-
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 inputvalues
and batches them together in groups. All values in a given group have the same derived value. The derived value is computed using thederiver
function. Two derived values are compared for equality using thecomparator
.- Type Parameters:
T
- the type of the valuesU
- the type of the derived values- Parameters:
values
- the input valuesderiver
- the function to compute a derived valuecomparator
- the equality test for derived values- Returns:
- a list of pairs with a derived values and the corresponding batch
- Since:
- 10.10
-