com.github.uuidcode.util.IntermediateOperation Maven / Gradle / Ivy
package com.github.uuidcode.util;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
public class IntermediateOperation {
private Function, Stream> intermediateFunction;
public static IntermediateOperation skip(Long index) {
return new IntermediateOperation()
.setIntermediateFunction(i -> i.skip(index));
}
public static IntermediateOperation map(Function mapper) {
return new IntermediateOperation()
.setIntermediateFunction(i -> i.map(mapper));
}
public static IntermediateOperation filter(Predicate predicate) {
return new IntermediateOperation().
setIntermediateFunction(i -> i.filter(predicate));
}
public IntermediateOperation setIntermediateFunction(Function, Stream> intermediateFunction) {
this.intermediateFunction = intermediateFunction;
return this;
}
public Stream run(Stream stream) {
return this.intermediateFunction.apply(stream);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy