org.opensearch.migrations.Utils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of coreUtilities Show documentation
Show all versions of coreUtilities Show documentation
Everything opensearch migrations
package org.opensearch.migrations;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
public class Utils {
private Utils() {}
/**
* See https://en.wikipedia.org/wiki/Fold_(higher-order_function)
*/
public static Collector foldLeft(
final B seedValue,
final BiFunction super B, ? super A, ? extends B> f
) {
return Collectors.collectingAndThen(
Collectors.reducing(Function.identity(), a -> b -> f.apply(b, a), Function::andThen),
finisherArg -> finisherArg.apply(seedValue)
);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy