Interface ResultPacker<T>

Type Parameters:
T - the type of object resulting from the packing

public interface ResultPacker<T>
A ResultPacker packs the contents of a ResultSet into a List.
  • Method Summary

    Modifier and Type
    Method
    Description
    get(ResultSet resultSet)
    Fetches a single instance from the given result set, assuming ResultSet.next() has been called
    default List<T>
    pack(ResultSet resultSet)
    Iterates through the given ResultSet, packing its contents into a List using get(ResultSet) in the order they appear.
  • Method Details

    • pack

      default List<T> pack(ResultSet resultSet) throws SQLException
      Iterates through the given ResultSet, packing its contents into a List using get(ResultSet) in the order they appear. Items are skipped if get(ResultSet) returns null. This method does not close or modify the ResultSet in any way.
      Parameters:
      resultSet - the ResultSet instance containing the query result to process
      Returns:
      a List containing the data from the query result
      Throws:
      SQLException - thrown if anything goes wrong during the packing
      NullPointerException - in case resultSet is null
    • get

      T get(ResultSet resultSet) throws SQLException
      Fetches a single instance from the given result set, assuming ResultSet.next() has been called
      Parameters:
      resultSet - the result set
      Returns:
      the instance fetched from the ResultSet
      Throws:
      SQLException - in case of failure