
com.tinkerpop.gremlin.process.util.TraversalRing Maven / Gradle / Ivy
package com.tinkerpop.gremlin.process.util;
import com.tinkerpop.gremlin.process.Traversal;
import java.io.Serializable;
import java.util.function.Consumer;
import java.util.stream.Stream;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class TraversalRing implements Serializable {
public Traversal[] traversals;
private int currentPipeline = -1;
public TraversalRing(final Traversal... traversals) {
this.traversals = traversals;
}
public Traversal next() {
this.currentPipeline = (this.currentPipeline + 1) % this.traversals.length;
return this.traversals[this.currentPipeline];
}
public void reset() {
this.currentPipeline = -1;
}
public int size() {
return this.traversals.length;
}
public Stream> stream() {
return Stream.of(this.traversals);
}
public void forEach(final Consumer> consumer) {
for (int i = 0; i < this.traversals.length; i++) {
consumer.accept(this.traversals[i]);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy