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

com.happy3w.toolkits.pipe.EasyPipe Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
package com.happy3w.toolkits.pipe;

import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;

public abstract class EasyPipe implements IEasyPipe {
    protected IEasyPipe nextPipe;

    public void flush() {
        nextPipe.flush();
    }

    public static  EasyPipeBuilder of(Class dataType) {
        return createBuilder(new HeadPipe<>());
    }

    public static  IEasyPipe end() {
        return new EndPipe();
    }

    public static  EasyPipeBuilder map(Function mapMethod) {
        return createBuilder(new MapPipe(mapMethod));
    }

    public static  EasyPipeBuilder> split(int size) {
        return createBuilder(new SplitPipe<>(size));
    }

    public static  EasyPipeBuilder visit(Consumer consumeMethod) {
        return createBuilder(new PeekPipe(consumeMethod));
    }

    public static  EasyPipeBuilder flatMap(Function> mapMethod) {
        return createBuilder(new FlatMapPipe(mapMethod));
    }

    public static  EasyPipeBuilder filter(Predicate predicate) {
        return createBuilder(new FilterPipe(predicate));
    }

    public static  EasyPipeBuilder filter(Predicate predicate, IEasyPipe elsePipe) {
        return createBuilder(new FilterPipe(predicate, elsePipe));
    }

    private static  EasyPipeBuilder createBuilder(EasyPipe pipe) {
        return new EasyPipeBuilder<>(pipe, pipe);
    }

    public static  ClassifyPipeBuilder classify(Function mapMethod) {
        ClassifyPipe pipe = new ClassifyPipe<>(mapMethod);
        return new ClassifyPipeBuilder(pipe, pipe);
    }

    public static  ConsumePipe forEach(Consumer consumer) {
        return new ConsumePipe(consumer);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy