Class MultiQueryIterator<E extends BasicItem>

java.lang.Object
net.sf.basedb.util.query.MultiQueryIterator<E>
All Implemented Interfaces:
Iterator<E>

public class MultiQueryIterator<E extends BasicItem> extends Object implements Iterator<E>
Helper class for executing multiple queries and return the result as a single iterator. The queries are executed in the order that they are given, if a query doesn't return any result, the iterator continues with the next query. As soon as a query returns at least one result, no more queries are executed.
Since:
3.2
Author:
nicklas
  • Field Details

    • dc

      private final DbControl dc
    • queries

      private final ItemQuery<? extends E extends BasicItem>[] queries
    • current

      private Iterator<? extends E extends BasicItem> current
    • nextQuery

      private int nextQuery
    • numReturned

      private int numReturned
  • Constructor Details

    • MultiQueryIterator

      private MultiQueryIterator(DbControl dc, ItemQuery<? extends E>[] queries)
  • Method Details

    • get

      @SafeVarargs public static <E extends BasicItem> Iterator<E> get(DbControl dc, ItemQuery<? extends E>... queries)
      Create a new iterator for the given list of queries. There must be at least one query.
      Parameters:
      dc - The DbControl to use when executing the queries
      queries - An array of queries to execute
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<E extends BasicItem>
    • next

      public E next()
      Specified by:
      next in interface Iterator<E extends BasicItem>
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<E extends BasicItem>