Package com.google.gerrit.index.query
Class LazyResultSet<T>
- java.lang.Object
-
- com.google.gerrit.index.query.LazyResultSet<T>
-
public class LazyResultSet<T> extends Object implements ResultSet<T>
Result set that allows for asynchronous execution of the actual query. Callers should dispatch the query and call the constructor of this class with a supplier that fetches the result and blocks on it if necessary.If the execution is synchronous or the results are known a priori, consider using
ListResultSet
.
-
-
Constructor Summary
Constructors Constructor Description LazyResultSet(Supplier<com.google.common.collect.ImmutableList<T>> r)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the result, discarding any further results.Iterator<T>
iterator()
Obtain an iterator to loop through the results.com.google.common.collect.ImmutableList<T>
toList()
Materialize all results as a single list.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
iterator
public Iterator<T> iterator()
Description copied from interface:ResultSet
Obtain an iterator to loop through the results.The iterator can be obtained only once. When the iterator completes (
hasNext()
returns false)ResultSet.close()
will be automatically called.
-
toList
public com.google.common.collect.ImmutableList<T> toList()
Description copied from interface:ResultSet
Materialize all results as a single list.Prior to returning
ResultSet.close()
is invoked. This method must not be combined withResultSet.iterator()
on the same instance.
-
-