Package com.gengoai.sql
Class ResultSetIterator<T>
- java.lang.Object
-
- com.gengoai.sql.ResultSetIterator<T>
-
- Type Parameters:
T
- the type of Object we will map the ResultSet to
- All Implemented Interfaces:
Serializable
,Iterator<T>
public class ResultSetIterator<T> extends Object implements Iterator<T>, Serializable
Wraps a ResultSet as an Iterator mapping the Result to an object with a given
ResultSetMapper
. This class takes care of closing the result when the underlying ResultSet is no longer in memory. Note that all SQLExceptions are rethrown as RuntimeException to fit within the Iterator paradigm.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ResultSetIterator(@NonNull ResultSetMapper<? extends T> mapper, @NonNull ResultSet resultSet)
Instantiates a new ResultSetIterator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasNext()
T
next()
-
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
-
ResultSetIterator
public ResultSetIterator(@NonNull @NonNull ResultSetMapper<? extends T> mapper, @NonNull @NonNull ResultSet resultSet)
Instantiates a new ResultSetIterator.- Parameters:
mapper
- the mapper taking a ResultSet and returning an ObjectresultSet
- the ResultSet to iterate over
-
-