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

org.pixel.pipeline.DataPipeline Maven / Gradle / Ivy

There is a newer version: 0.10.0
Show newest version
/*
 * This software is available under Apache License
 * Copyright (c)
 */

package org.pixel.pipeline;

import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.concurrent.CompletableFuture;

public class DataPipeline {

    private final LinkedList> handlerList;

    /**
     * Constructor.
     */
    public DataPipeline() {
        this.handlerList = new LinkedList<>();
    }

    /**
     * Constructor.
     *
     * @param handlers The handlers to add to the pipeline.
     */
    @SafeVarargs
    public DataPipeline(PipelineHandler... handlers) {
        this.handlerList = new LinkedList<>();
        Collections.addAll(this.handlerList, handlers);
    }

    /**
     * Begin processing the data.
     *
     * @param data The data to process.
     */
    public CompletableFuture begin(T data) {
        var future = new CompletableFuture();
        new PipelineContext<>(this, future).next(data);

        return future;
    }

    /**
     * Get the handler list iterator.
     *
     * @return The handler list iterator.
     */
    public Iterator> getHandlerIterator() {
        return this.handlerList.iterator();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy