org.simpleflatmapper.util.EnumerableSpliterator 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.Spliterator;
import java.util.function.Consumer;
public class EnumerableSpliterator implements Spliterator {
private final Enumerable enumerable;
public EnumerableSpliterator(Enumerable enumerable) {
this.enumerable = enumerable;
}
@Override
public boolean tryAdvance(Consumer super T> action) {
Enumerable lEnumerable = this.enumerable;
if (lEnumerable.next()) {
action.accept(lEnumerable.currentValue());
return true;
} else {
return false;
}
}
@Override
public void forEachRemaining(Consumer super T> action) {
Enumerable lEnumerable = this.enumerable;
while(lEnumerable.next()) {
action.accept(lEnumerable.currentValue());
}
}
@Override
public Spliterator trySplit() {
return null;
}
@Override
public long estimateSize() {
return Long.MAX_VALUE;
}
@Override
public int characteristics() {
return ORDERED;
}
}