net.sourceforge.plantuml.version.IteratorCounter2Impl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.version;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.text.StringLocated;
public class IteratorCounter2Impl implements IteratorCounter2 {
private List data;
private List trace;
private int nb;
public void copyStateFrom(IteratorCounter2 other) {
final IteratorCounter2Impl source = (IteratorCounter2Impl) other;
this.nb = source.nb;
this.data = source.data;
this.trace = source.trace;
}
public IteratorCounter2Impl(List data) {
this(data, 0, new ArrayList());
}
private IteratorCounter2Impl(List data, int nb, List trace) {
this.data = data;
this.nb = nb;
this.trace = trace;
}
public IteratorCounter2 cloneMe() {
return new IteratorCounter2Impl(data, nb, new ArrayList<>(trace));
}
public int currentNum() {
return nb;
}
public boolean hasNext() {
return nb < data.size();
}
public StringLocated next() {
final StringLocated result = data.get(nb);
nb++;
trace.add(result);
return result;
}
public StringLocated peek() {
return data.get(nb);
}
public StringLocated peekPrevious() {
if (nb == 0) {
return null;
}
return data.get(nb - 1);
}
public void remove() {
throw new UnsupportedOperationException();
}
public final List getTrace() {
return Collections.unmodifiableList(trace);
}
}