com.github.fridujo.junit.extension.classpath.Streams Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of classpath-junit-extension Show documentation
Show all versions of classpath-junit-extension Show documentation
JUnit5 extension to run tests with classpath customizations
The newest version!
package com.github.fridujo.junit.extension.classpath;
import java.util.Iterator;
import java.util.function.BiFunction;
import java.util.stream.Stream;
public class Streams {
public static U reduce(Stream stream, U initialValue, BiFunction accumulator) {
U value = initialValue;
Iterator iterator = stream.iterator();
while (iterator.hasNext()) {
value = accumulator.apply(value, iterator.next());
}
return value;
}
}