Skip to content

Instantly share code, notes, and snippets.

@okram
Created August 18, 2014 19:18
Show Gist options
  • Save okram/b38ff96b8c334c63752c to your computer and use it in GitHub Desktop.
Save okram/b38ff96b8c334c63752c to your computer and use it in GitHub Desktop.
public class InjectStep<S> extends FilterStep<S> implements TraverserSource {
private final List<S> injections;
public InjectStep(final Traversal traversal, final S... injections) {
super(traversal);
this.setPredicate(t -> true);
this.injections = Arrays.asList(injections);
}
public void generateTraverserIterator(final boolean trackPaths) {
if (trackPaths)
this.addStarts(new TraverserIterator<>(this, this.injections.iterator()));
else
this.addStarts(new TraverserIterator<>(this.injections.iterator()));
}
public void clear() {
this.starts.clear();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment