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

no.ssb.lds.api.persistence.flattened.FlattenedDocumentIterator Maven / Gradle / Ivy

There is a newer version: 0.13
Show newest version
package no.ssb.lds.api.persistence.flattened;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CompletableFuture;

public class FlattenedDocumentIterator implements Iterable, Iterator {

    private final Iterator iterator;

    FlattenedDocumentIterator(List matches) {
        if (matches == null) {
            this.iterator = Collections.emptyListIterator();
        } else {
            this.iterator = matches.iterator();
        }
    }

    /**
     * Returns a completable future that when complete signals whether or not the next() method will return another
     * element, and allows next to be called without blocking.
     * 

* This should be used as an asynchronous callback when the iterator has more elements. * * @return */ public CompletableFuture onHasNext() { return CompletableFuture.completedFuture(hasNext()); } @Override public Iterator iterator() { return this; } @Override public boolean hasNext() { return iterator.hasNext(); } @Override public FlattenedDocument next() { return iterator.next(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy