Package com.tinkerpop.pipes.util

Source Code of com.tinkerpop.pipes.util.StartPipe

package com.tinkerpop.pipes.util;

import com.tinkerpop.pipes.IdentityPipe;
import com.tinkerpop.pipes.util.iterators.SingleIterator;

import java.util.Iterator;

/**
* StartPipe is a handy way to create a pipe out of the provided object.
* The provided object is set as the start of the Pipe that simply emits the object or
* if the object is an iterator/iterable, the objects of the object.
*
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class StartPipe<S> extends IdentityPipe<S> {

    public StartPipe(final Object start) {
        if (start instanceof Iterator) {
            super.setStarts((Iterator) start);
        } else if (start instanceof Iterable) {
            super.setStarts((Iterable) start);
        } else {
            super.setStarts(new SingleIterator(start));
        }
    }
}
TOP

Related Classes of com.tinkerpop.pipes.util.StartPipe

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.