Interface DbRow


public interface DbRow
Representation of a single row in a database (in SQL this would be a row, in a Document DB, this would be a single document).
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    as(GenericType<T> type)
    Map this row to an object using a DbMapper.
    <T> T
    as(Class<T> type)
    Get specific class instance representation of this row.
    <T> T
    as(Function<DbRow,T> mapper)
    Get specific class instance representation of this row.
    column(int index)
    Get a column in this row.
    column(String name)
    Get a column in this row.
    void
    forEach(Consumer<? super DbColumn> columnAction)
    Iterate through each column in this row.
  • Method Details

    • column

      DbColumn column(String name)
      Get a column in this row. Column is identified by its name.
      Parameters:
      name - column name
      Returns:
      a column in this row
    • column

      DbColumn column(int index)
      Get a column in this row. Column is identified by its index.
      Parameters:
      index - column index starting from 1
      Returns:
      a column in this row
    • forEach

      void forEach(Consumer<? super DbColumn> columnAction)
      Iterate through each column in this row.
      Parameters:
      columnAction - what to do with each column
    • as

      <T> T as(Class<T> type) throws MapperException
      Get specific class instance representation of this row. Mapper for target class must be already registered.
      Type Parameters:
      T - type of the returned value
      Parameters:
      type - class of the returned value type
      Returns:
      instance of requested class containing this database row
      Throws:
      MapperException - in case the mapping is not defined or fails
    • as

      <T> T as(GenericType<T> type) throws MapperException
      Map this row to an object using a DbMapper.
      Type Parameters:
      T - type to be returned
      Parameters:
      type - type that supports generic declarations
      Returns:
      typed row
      Throws:
      MapperException - in case the mapping is not defined or fails
      MapperException - in case the mapping is not defined or fails
    • as

      <T> T as(Function<DbRow,T> mapper)
      Get specific class instance representation of this row. Mapper for target class is provided as an argument.
      Type Parameters:
      T - type of the returned value
      Parameters:
      mapper - method to create an target class instance from DbRow
      Returns:
      instance of requested class containing this database row