org.simpleflatmapper.util.EnumarableIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-util Show documentation
Show all versions of sfm-util Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.simpleflatmapper.util;
import java.util.Iterator;
import java.util.NoSuchElementException;
public class EnumarableIterator implements Iterator {
private final Enumarable enumarable;
private boolean fetch = false;
private boolean hasValue = false;
public EnumarableIterator(Enumarable enumarable) {
this.enumarable = enumarable;
}
@Override
public boolean hasNext() {
if (!fetch) {
fetch();
}
return hasValue;
}
private void fetch() {
hasValue = enumarable.next();
fetch = true;
}
@Override
public T next() {
if (!fetch) {
fetch();
}
if (hasValue) {
fetch = false;
hasValue = false;
return enumarable.currentValue();
} else {
throw new NoSuchElementException();
}
}
@Override
public void remove() {
throw new UnsupportedOperationException("remove");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy