All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.uuidcode.util.IntermediateOperation Maven / Gradle / Ivy

There is a newer version: 0.0.64
Show newest version
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