Class 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 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 Object
        resultSet - the ResultSet to iterate over
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface Iterator<T>
      • next

        public T next()
        Specified by:
        next in interface Iterator<T>