Class PojoMapper<T>
- java.lang.Object
-
- org.jdbi.v3.core.mapper.reflect.internal.PojoMapper<T>
-
- All Implemented Interfaces:
RowMapper<T>
- Direct Known Subclasses:
BeanMapper
public class PojoMapper<T> extends java.lang.Object implements RowMapper<T>
This class is the future home of BeanMapper functionality.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classPojoMapper.BoundPojoMapperprivate static classPojoMapper.PropertyData<T>
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<PojoProperties.PojoProperty<T>,PojoMapper<?>>nestedMappersprotected java.lang.Stringprefixprotected booleanstrictColumnTypeMappingprotected java.lang.reflect.Typetype
-
Constructor Summary
Constructors Constructor Description PojoMapper(java.lang.reflect.Type type, java.lang.String prefix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected PojoMapper<?>createNestedMapper(StatementContext ctx, PojoProperties.PojoProperty<T> property, java.lang.String nestedPrefix)private java.util.Optional<RowMapper<T>>createSpecializedRowMapper(StatementContext ctx, java.util.List<java.lang.String> columnNames, java.util.List<ColumnNameMatcher> columnNameMatchers, java.util.List<java.lang.String> unmatchedColumns)private java.lang.StringdebugName(PojoProperties.PojoProperty<T> p)private java.lang.StringgetName(PojoProperties.PojoProperty<T> property)protected PojoProperties<T>getProperties(ConfigRegistry config)private java.util.OptionalIntlocatePropagateNullColumnIndex(java.util.List<java.lang.String> columnNames, java.util.List<ColumnNameMatcher> columnNameMatchers)Tmap(java.sql.ResultSet rs, StatementContext ctx)Map the current row of the result set.RowMapper<T>specialize(java.sql.ResultSet rs, StatementContext ctx)Returns a specialized row mapper, optimized for the given result set.
-
-
-
Field Detail
-
strictColumnTypeMapping
protected boolean strictColumnTypeMapping
-
type
protected final java.lang.reflect.Type type
-
prefix
protected final java.lang.String prefix
-
nestedMappers
private final java.util.Map<PojoProperties.PojoProperty<T>,PojoMapper<?>> nestedMappers
-
-
Method Detail
-
map
public T map(java.sql.ResultSet rs, StatementContext ctx) throws java.sql.SQLException
Description copied from interface:RowMapperMap the current row of the result set. This method should not cause the result set to advance; allow Jdbi to do that, please.
-
specialize
public RowMapper<T> specialize(java.sql.ResultSet rs, StatementContext ctx) throws java.sql.SQLException
Description copied from interface:RowMapperReturns a specialized row mapper, optimized for the given result set.Before mapping the result set from a SQL statement; Jdbi will first call this method to obtain a specialized instance. The returned mapper will then be used to map the result set rows, and discarded.
Implementing this method is optional; the default implementation returns
this. Implementors might choose to override this method to improve performance, e.g. by matching up column names to properties once for the entire result set, rather than repeating the process for every row.- Specified by:
specializein interfaceRowMapper<T>- Parameters:
rs- the result set to specialize overctx- the statement context to specialize over- Returns:
- a row mapper equivalent to this one, possibly specialized.
- Throws:
java.sql.SQLException- if anything goes wrong go ahead and let this percolate; Jdbi will handle it- See Also:
for an example of specialization.
-
createSpecializedRowMapper
private java.util.Optional<RowMapper<T>> createSpecializedRowMapper(StatementContext ctx, java.util.List<java.lang.String> columnNames, java.util.List<ColumnNameMatcher> columnNameMatchers, java.util.List<java.lang.String> unmatchedColumns)
-
locatePropagateNullColumnIndex
private java.util.OptionalInt locatePropagateNullColumnIndex(java.util.List<java.lang.String> columnNames, java.util.List<ColumnNameMatcher> columnNameMatchers)
-
getProperties
protected PojoProperties<T> getProperties(ConfigRegistry config)
-
createNestedMapper
protected PojoMapper<?> createNestedMapper(StatementContext ctx, PojoProperties.PojoProperty<T> property, java.lang.String nestedPrefix)
-
getName
private java.lang.String getName(PojoProperties.PojoProperty<T> property)
-
debugName
private java.lang.String debugName(PojoProperties.PojoProperty<T> p)
-
-