Class BatchUtils

    • Method Detail

      • 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
        values - the input values
        deriver - the function to compute a derived value
        comparator - the equality test for derived values
        a list of pairs with a derived values and the corresponding batch