Interface Mappable<T>

All Known Implementing Classes:
EntityMapper, FieldMapper

public interface Mappable<T>
Author:
Collin Alpert
  • Method Details

    • map

      Optional<T> map​(ResultSet set) throws SQLException
      Maps a ResultSet to an Optional. Should be used when only one result is expected from the database.
      Parameters:
      set - The ResultSet to get the data from.
      Returns:
      An Optional containing the ResultSets data.
      Throws:
      SQLException - In case the ResultSet can't be read.
    • mapToList

      List<T> mapToList​(ResultSet set) throws SQLException
      Maps a ResultSet to a List.
      Parameters:
      set - The ResultSet to get the data from.
      Returns:
      A List containing the ResultSets data.
      Throws:
      SQLException - In case the ResultSet can't be read.
    • mapToStream

      Stream<T> mapToStream​(ResultSet set) throws SQLException
      Maps a ResultSet to a Stream.
      Parameters:
      set - The ResultSet to get the data from.
      Returns:
      A Stream containing the ResultSets data.
      Throws:
      SQLException - In case the ResultSet can't be read.
    • mapToArray

      T[] mapToArray​(ResultSet set) throws SQLException
      Maps a ResultSet to an array.
      Parameters:
      set - The ResultSet to get the data from.
      Returns:
      An array containing the ResultSets data.
      Throws:
      SQLException - In case the ResultSet can't be read.
    • mapToMap

      default <K> Map<K,​T> mapToMap​(ResultSet set, Function<T,​K> keyMapping) throws SQLException
      Maps a ResultSet to a Map.
      Type Parameters:
      K - The type of the keys in the map.
      Parameters:
      set - The ResultSet to get the data from.
      keyMapping - The key function of the map.
      Returns:
      A Map containing the ResultSets data.
      Throws:
      SQLException - In case the ResultSet can't be read.
    • mapToMap

      <K,​ V> Map<K,​V> mapToMap​(ResultSet set, Function<T,​K> keyMapping, Function<T,​V> valueMapping) throws SQLException
      Maps a ResultSet to a Map.
      Type Parameters:
      K - The type of the keys in the map.
      V - The type of the values in the map.
      Parameters:
      set - The ResultSet to get the data from.
      keyMapping - The key function of the map.
      valueMapping - The value function of the map.
      Returns:
      A Map containing the ResultSets data.
      Throws:
      SQLException - In case the ResultSet can't be read.