All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.simpleflatmapper.util.EnumerableSpliterator Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

The newest version!
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 action) {
        Enumerable lEnumerable = this.enumerable;
        if (lEnumerable.next()) {
            action.accept(lEnumerable.currentValue());
            return true;
        } else {
            return false;
        }
    }

    @Override
    public void forEachRemaining(Consumer 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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy