org.reflections8.util.AbstractIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of reflections8 Show documentation
Show all versions of reflections8 Show documentation
Reflections8 - a Java runtime metadata analysis without guava on Java 8
package org.reflections8.util;
import java.util.Iterator;
import java.util.NoSuchElementException;
public abstract class AbstractIterator implements Iterator {
private T tmp = null;
private boolean endOfData = false;
protected T endOfData() {
endOfData = true;
return null;
}
protected abstract T computeNext();
public T next() {
if (endOfData || !hasNext()) {
throw new NoSuchElementException("nothing left");
}
T res = tmp;
tmp = null;
return res;
}
@Override
public boolean hasNext() {
if (tmp != null)
return true;
tmp = computeNext();
return !endOfData;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy