Package no.digipost.jdbc
Interface ColumnMapper<R>
-
- Type Parameters:
R- The type of object thisColumnMapperyields from aResultSet
- All Known Subinterfaces:
BasicColumnMapper<R>,NullableColumnMapper<R>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface ColumnMapper<R>
AColumnMapperdiffer from aRowMapperin that it is also given a column label/name together with theResultSet, which can be used to process specific column(s). Typically, aColumnMapperdefines how a extract the value from a certain type of columns, sayINT,VARCHAR, orTIMESTAMPcolumns. Mappers for these value types and other common basic mappers can be found in theMappersclass. AColumnMappercan be specialized to handle one specific column withforColumn(Attribute), which turns it into aRowMapper.- See Also:
BasicColumnMapper,NullableColumnMapper
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default AttributeMapper<R>forColumn(Attribute<R> attribute)Associate the column mapper with anAttribute.Rmap(String name, ResultSet resultSet)Extract a value from aResultSetbased on the givenname.
-
-
-
Method Detail
-
map
R map(String name, ResultSet resultSet) throws SQLException
Extract a value from aResultSetbased on the givenname. Usually the name is the column name, or column label if an SQLASclause was used in the query. The givenResultSetis expected to be positioned at the "current" row, i.e. theColumnMapperis not expected to be required to do any cursor placement before doing any value extraction.- Parameters:
name- the name of the value to extract, usually the column name, or column label if an SQLASclause was used in the query.resultSet- theResultSetto extract from.- Returns:
- The reulting extracted value.
- Throws:
SQLException- if any error happens when processing theResultSet. May be if the name/label is not valid, if a database access error occurs, or this method is called on a closed result set.
-
forColumn
default AttributeMapper<R> forColumn(Attribute<R> attribute)
Associate the column mapper with anAttribute. This will create a row mapper for the column named by the givenattribute.- Returns:
- a new
AttributeMapper, which is a row mapper.
-
-