/** * Initialize this pipe to apply its conditions to the given pipe. * Each object in the source pipe is fed into the given pipe individually. * * @param pipe The pipe to determine if objects exist after input processed */ public HasNextPipe(final Pipe<S, ?> pipe) { this.pipe = pipe; this.pipe.setStarts(this.expando); }
protected List getPathToHere() { return this.pipe.getCurrentPath(); }
/** * Get the next object emitted from the pipeline. * If no such object exists, then a NoSuchElementException is thrown. * * @return the next emitted object */ public E next() { return this.endPipe.next(); }
/** * Determines if there is another object that can be emitted from the pipeline. * * @return true if an object can be next()'d out of the pipeline */ public boolean hasNext() { return this.endPipe.hasNext(); }
public void enablePath(final boolean enable) { this.pathEnabled = enable; if (this.starts instanceof Pipe) ((Pipe) this.starts).enablePath(enable); }
public void setStarts(final Pipe<?, S> starts) { this.setStarts(starts.iterator()); }
public S processNextStart() { int counter = 0; while (true) { counter++; final Pipe currentPipe = this.pipes.get(this.current); if (currentPipe.hasNext()) { final S s = (S) currentPipe.next(); this.current = (this.current + 1) % this.total; return s; } else if (counter == this.total) { throw FastNoSuchElementException.instance(); } else { this.current = (this.current + 1) % this.total; } } }
public E processNextStart() { return this.pipe.next(); }
@Override public boolean hasNext() { return pipe.hasNext(); }
public void enablePath(final boolean enable) { this.pathEnabled = enable; if (this.starts instanceof Pipe) ((Pipe) this.starts).enablePath(enable); }
public void setStarts(final Iterator<S> starts) { this.pipe.setStarts(starts); this.starts = starts; }
public List getCurrentPath() { if (this.pathEnabled) return this.endPipe.getCurrentPath(); else throw new RuntimeException(Pipe.NO_PATH_MESSAGE); }
public S processNextStart() { final S s = this.starts.next(); this.expando.add(s); try { while (true) { this.pipe.next(); } } catch (final NoSuchElementException e) { } return s; }
public void enablePath(final boolean enable) { this.pathEnabled = enable; this.endPipe.enablePath(enable); }