Class AbstractDelegatingResultReader<RS,ID>

java.lang.Object
io.micronaut.data.runtime.mapper.AbstractDelegatingResultReader<RS,ID>
Type Parameters:
RS - The result set
ID - The index type
All Implemented Interfaces:
ResultReader<RS,ID>
Direct Known Subclasses:
ColumnNameExistenceAwareCallableResultReader, ColumnNameExistenceAwareR2dbcResultSetReader, ColumnNameExistenceAwareReadableR2dbcResultReader, ColumnNameExistenceAwareResultSetReader

@Internal public abstract class AbstractDelegatingResultReader<RS,ID> extends Object implements ResultReader<RS,ID>
The delegating ResultReader.
Since:
4.9
Author:
Denis Stepanov
  • Field Details

  • Constructor Details

    • AbstractDelegatingResultReader

      protected AbstractDelegatingResultReader(ResultReader<RS,ID> delegate)
  • Method Details

    • convertRequired

      public <T> T convertRequired(Object value, Class<T> type)
      Description copied from interface: ResultReader
      Convert the value to the given type.
      Specified by:
      convertRequired in interface ResultReader<RS,ID>
      Type Parameters:
      T - The generic type
      Parameters:
      value - The value
      type - The type
      Returns:
      The converted value
    • convertRequired

      public <T> T convertRequired(Object value, io.micronaut.core.type.Argument<T> type)
      Description copied from interface: ResultReader
      Convert the value to the given type.
      Specified by:
      convertRequired in interface ResultReader<RS,ID>
      Type Parameters:
      T - The generic type
      Parameters:
      value - The value
      type - The type
      Returns:
      The converted value
    • getRequiredValue

      public <T> @Nullable T getRequiredValue(RS resultSet, ID name, Class<T> type) throws DataAccessException
      Description copied from interface: ResultReader
      Get a value from the given result set for the given name and type.
      Specified by:
      getRequiredValue in interface ResultReader<RS,ID>
      Type Parameters:
      T - The generic type
      Parameters:
      resultSet - The result set
      name - The name
      type - The type
      Returns:
      The value
      Throws:
      DataAccessException - if the value cannot be read
    • getRequiredValueNonNull

      public <T> T getRequiredValueNonNull(RS resultSet, ID name, Class<T> type) throws DataAccessException
      Description copied from interface: ResultReader
      Get a value from the given result set for the given name and type.
      Specified by:
      getRequiredValueNonNull in interface ResultReader<RS,ID>
      Type Parameters:
      T - The generic type
      Parameters:
      resultSet - The result set
      name - The name
      type - The type
      Returns:
      The value
      Throws:
      DataAccessException - if the value cannot be read
    • next

      public boolean next(RS resultSet)
      Description copied from interface: ResultReader
      Move the index to the next result if possible.
      Specified by:
      next in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      Returns:
      The next result
    • findColumnIndex

      public int findColumnIndex(RS resultSet, String columnName)
      Description copied from interface: ResultReader
      Resolves the ordinal of the column with the given name in the result set, so that callers can cache it and read the values of subsequent rows by index using ResultReader.getColumnIndexReader() instead of resolving the column name for every row.

      The returned ordinal is only valid for the given result set and uses the index convention of the underlying driver (for example 1-based for JDBC). Readers that cannot resolve column ordinals return -1, in which case callers must keep reading by name.

      Specified by:
      findColumnIndex in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      columnName - The column name
      Returns:
      The column index or -1 if the column cannot be resolved
    • getColumnIndexReader

      public @Nullable ResultReader<RS,Integer> getColumnIndexReader()
      Description copied from interface: ResultReader
      The reader capable of reading values by the ordinals resolved by ResultReader.findColumnIndex(Object, String).
      Specified by:
      getColumnIndexReader in interface ResultReader<RS,ID>
      Returns:
      The column index reader or null if reading by column index is not supported
    • columnResolutionKey

      public Object columnResolutionKey(RS resultSet)
      Description copied from interface: ResultReader
      The object the resolved column ordinals belong to, compared by identity by callers that cache them. It is the result set itself when the result set spans every row, which is the case for JDBC. Readers whose result set object is a single row, which is the case for R2DBC, return something shared by the rows of one result, such as the row metadata, so that the ordinals survive from one row to the next.

      Returning a different object per row is safe: the ordinals are then resolved again for each row.

      Specified by:
      columnResolutionKey in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      Returns:
      The object the resolved ordinals belong to
    • readDynamic

      public @Nullable Object readDynamic(RS resultSet, ID index, DataType dataType)
      Description copied from interface: ResultReader
      Read a value dynamically using the result set and the given name and data type.
      Specified by:
      readDynamic in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      index - The name
      dataType - The data type
      Returns:
      The value, can be null
    • readLong

      public long readLong(RS resultSet, ID name)
      Description copied from interface: ResultReader
      Read a long value for the given name.
      Specified by:
      readLong in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The long value
    • readChar

      public char readChar(RS resultSet, ID name)
      Description copied from interface: ResultReader
      Read a char value for the given name.
      Specified by:
      readChar in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The char value
    • readDate

      public @Nullable Date readDate(RS resultSet, ID name)
      Description copied from interface: ResultReader
      Read a date value for the given name.
      Specified by:
      readDate in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The char value
    • readTimestamp

      public @Nullable Date readTimestamp(RS resultSet, ID index)
      Description copied from interface: ResultReader
      Read a timestamp value for the given index.
      Specified by:
      readTimestamp in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      index - The index (such as the column name)
      Returns:
      The char value
    • readTime

      public @Nullable Time readTime(RS resultSet, ID index)
      Description copied from interface: ResultReader
      Read a time value for the given index.
      Specified by:
      readTime in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      index - The index (such as the column name)
      Returns:
      The char value
    • readString

      public @Nullable String readString(RS resultSet, ID name)
      Description copied from interface: ResultReader
      Read a string value for the given name.
      Specified by:
      readString in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The string value
    • readUUID

      public @Nullable UUID readUUID(RS resultSet, ID name)
      Description copied from interface: ResultReader
      Read a UUID value for the given name.
      Specified by:
      readUUID in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The string value
    • readInt

      public int readInt(RS resultSet, ID name)
      Description copied from interface: ResultReader
      Read an int value for the given name.
      Specified by:
      readInt in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The int value
    • readBoolean

      public boolean readBoolean(RS resultSet, ID name)
      Description copied from interface: ResultReader
      Read a boolean value for the given name.
      Specified by:
      readBoolean in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The boolean value
    • readFloat

      public float readFloat(RS resultSet, ID name)
      Description copied from interface: ResultReader
      Read a float value for the given name.
      Specified by:
      readFloat in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The float value
    • readByte

      public byte readByte(RS resultSet, ID name)
      Description copied from interface: ResultReader
      Read a byte value for the given name.
      Specified by:
      readByte in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The byte value
    • readShort

      public short readShort(RS resultSet, ID name)
      Description copied from interface: ResultReader
      Read a short value for the given name.
      Specified by:
      readShort in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The short value
    • readDouble

      public double readDouble(RS resultSet, ID name)
      Description copied from interface: ResultReader
      Read a double value for the given name.
      Specified by:
      readDouble in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The double value
    • readBigDecimal

      public @Nullable BigDecimal readBigDecimal(RS resultSet, ID name)
      Description copied from interface: ResultReader
      Read a BigDecimal value for the given name.
      Specified by:
      readBigDecimal in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The BigDecimal value
    • readBytes

      public byte @Nullable [] readBytes(RS resultSet, ID name)
      Description copied from interface: ResultReader
      Read a byte[] value for the given name.
      Specified by:
      readBytes in interface ResultReader<RS,ID>
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The byte[] value
    • getConversionService

      public io.micronaut.core.convert.ConversionService getConversionService()
      Description copied from interface: ResultReader
      Get conversion service.
      Specified by:
      getConversionService in interface ResultReader<RS,ID>
      Returns:
      the instance of ConversionService