Class PageIterator<E>

  • Type Parameters:
    E - The type of elements in the page.
    All Implemented Interfaces:
    java.util.Iterator<Page<E>>

    public class PageIterator<E>
    extends java.lang.Object
    implements java.util.Iterator<Page<E>>
    PageIterator iterates over paged responses from Fauna, the default page size is 16.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Query buildPageQuery​(AfterToken afterToken)
      Build the page query with a specific AfterToken.
      java.util.Iterator<E> flatten()
      Return an iterator that iterates directly over the items that make up the page contents.
      boolean hasNext()
      Check if there is a next page available.
      Page<E> next()
      Get the next Page.
      java.util.concurrent.CompletableFuture<Page<E>> nextAsync()
      Returns a CompletableFuture that will complete with the next page (or throw a FaunaException).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, remove
    • Constructor Detail

      • PageIterator

        public PageIterator​(FaunaClient client,
                            Query fql,
                            java.lang.Class<E> resultClass,
                            QueryOptions options)
        Construct a new PageIterator.
        Parameters:
        client - A client that makes requests to Fauna.
        fql - The FQL query.
        resultClass - The class of the elements returned from Fauna (i.e., the rows).
        options - (optionally) pass in QueryOptions.
      • PageIterator

        public PageIterator​(FaunaClient client,
                            Page<E> firstPage,
                            java.lang.Class<E> resultClass,
                            QueryOptions options)
        Construct a new PageIterator starting from a given page.
        Parameters:
        client - A client that makes requests to Fauna.
        firstPage - The first Page of elements.
        resultClass - The class of the elements returned from Fauna (i.e., the rows).
        options - (optionally) pass in QueryOptions.
    • Method Detail

      • hasNext

        public boolean hasNext()
        Check if there is a next page available.
        Specified by:
        hasNext in interface java.util.Iterator<E>
        Returns:
        True if there is a next page, false otherwise.
      • buildPageQuery

        public static Query buildPageQuery​(AfterToken afterToken)
        Build the page query with a specific AfterToken.
        Parameters:
        afterToken - The token indicating where the next page should start.
        Returns:
        A Query to fetch the next page.
      • nextAsync

        public java.util.concurrent.CompletableFuture<Page<E>> nextAsync()
        Returns a CompletableFuture that will complete with the next page (or throw a FaunaException).
        Returns:
        A CompletableFuture representing the next page of elements.
      • next

        public Page<E> next()
        Get the next Page.
        Specified by:
        next in interface java.util.Iterator<E>
        Returns:
        The next Page of elements E.
        Throws:
        FaunaException - If there is an error getting the next page.
      • flatten

        public java.util.Iterator<E> flatten()
        Return an iterator that iterates directly over the items that make up the page contents.
        Returns:
        An iterator of E.