![JAR search and dependency download from the Maven repository](/logo.png)
org.sfm.utils.ForEachIteratorSpliterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simpleFlatMapper Show documentation
Show all versions of simpleFlatMapper Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.sfm.utils;
import java.util.Spliterator;
import java.util.function.Consumer;
public class ForEachIteratorSpliterator implements Spliterator {
private final ForEachIterator iterator;
public ForEachIteratorSpliterator(ForEachIterator iterator) {
this.iterator = iterator;
}
@Override
public boolean tryAdvance(Consumer super T> action) {
try {
return iterator.next(new RowHandler() {
@Override
public void handle(T t) throws Exception {
action.accept(t);
}
});
} catch (Exception e) {
return ErrorHelper.rethrow(e);
}
}
@Override
public void forEachRemaining(Consumer super T> action) {
try {
iterator.forEach(new RowHandler() {
@Override
public void handle(T t) throws Exception {
action.accept(t);
}
});
} catch (Exception e) {
ErrorHelper.rethrow(e);
}
}
@Override
public Spliterator trySplit() {
return null;
}
@Override
public long estimateSize() {
return Long.MAX_VALUE;
}
@Override
public int characteristics() {
return Spliterator.ORDERED | Spliterator.NONNULL;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy