org.zalando.logbook.Fold Maven / Gradle / Ivy
package org.zalando.logbook;
import java.util.Collection;
import java.util.function.BiFunction;
import java.util.function.BinaryOperator;
final class Fold {
private Fold() {
}
static R fold(
final Collection collection,
final R seed,
final BiFunction accumulator) {
return collection.stream()
.reduce(seed, accumulator, throwingCombiner());
}
@SuppressWarnings("unchecked")
private static BinaryOperator throwingCombiner() {
return (BinaryOperator) NoCombiner.NONE;
}
// visible for testing
enum NoCombiner implements BinaryOperator
© 2015 - 2025 Weber Informatics LLC | Privacy Policy