Class BaseMapper<T extends BaseEntity>

  • All Implemented Interfaces:
    Mapper<T>

    public class BaseMapper<T extends BaseEntity>
    extends java.lang.Object
    implements Mapper<T>
    Default mapper for converting a ResultSet to the respective Java entity.
    Author:
    Collin Alpert
    • Constructor Summary

      Constructors 
      Constructor Description
      BaseMapper​(java.lang.Class<T> clazz)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<T> map​(java.sql.ResultSet set)
      Maps a ResultSet with a single row to a Java entity.
      java.util.List<T> mapToList​(java.sql.ResultSet set)
      Maps a ResultSet with multiple rows to a list of Java entities.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BaseMapper

        public BaseMapper​(java.lang.Class<T> clazz)
    • Method Detail

      • map

        public java.util.Optional<T> map​(java.sql.ResultSet set)
                                  throws java.sql.SQLException
        Maps a ResultSet with a single row to a Java entity.
        Specified by:
        map in interface Mapper<T extends BaseEntity>
        Parameters:
        set - The ResultSet to map.
        Returns:
        An Optional which contains the Java entity if the query was successful.
        Throws:
        java.sql.SQLException - if the ResultSet.next() call does not work as expected.
      • mapToList

        public java.util.List<T> mapToList​(java.sql.ResultSet set)
                                    throws java.sql.SQLException
        Maps a ResultSet with multiple rows to a list of Java entities.
        Specified by:
        mapToList in interface Mapper<T extends BaseEntity>
        Parameters:
        set - The ResultSet to map.
        Returns:
        A list of Java entities.
        Throws:
        java.sql.SQLException - if the ResultSet.next() call does not work as expected.