public class ConstructorMapper<T> extends Object implements RowMapper<T>
| Modifier and Type | Method and Description |
|---|---|
static RowMapperFactory |
factory(Class<?> clazz)
Use the only declared constructor to map a class.
|
static RowMapperFactory |
factory(Class<?> clazz,
String prefix)
Use the only declared constructor to map a class.
|
static RowMapperFactory |
factory(Constructor<?> constructor)
Use a
Constructor<T> to map its declaring type. |
static RowMapperFactory |
factory(Constructor<?> constructor,
String prefix)
Use a
Constructor<T> to map its declaring type. |
T |
map(ResultSet rs,
StatementContext ctx)
Map the row the result set is at when passed in.
|
static <T> RowMapper<T> |
of(Class<T> type)
Return a ConstructorMapper for the given type.
|
static <T> RowMapper<T> |
of(Class<T> type,
String prefix)
Return a ConstructorMapper for the given type and prefix.
|
static <T> RowMapper<T> |
of(Constructor<T> constructor)
Return a ConstructorMapper using the given constructor
|
static <T> RowMapper<T> |
of(Constructor<T> constructor,
String prefix)
Instantiate a ConstructorMapper using the given constructor and prefix
|
RowMapper<T> |
specialize(ResultSet rs,
StatementContext ctx)
Returns a specialized row mapper, optimized for the given result set.
|
public static RowMapperFactory factory(Class<?> clazz)
clazz - the class to find a constructor ofpublic static RowMapperFactory factory(Class<?> clazz, String prefix)
clazz - the class to find a constructor ofprefix - a prefix for the parameter namespublic static RowMapperFactory factory(Constructor<?> constructor)
Constructor<T> to map its declaring type.constructor - the constructor to invokepublic static RowMapperFactory factory(Constructor<?> constructor, String prefix)
Constructor<T> to map its declaring type.constructor - the constructor to invokeprefix - a prefix to the constructor parameter namespublic T map(ResultSet rs, StatementContext ctx) throws SQLException
RowMappermap in interface RowMapper<T>rs - the result set being iteratedctx - the statement contextSQLException - if anything goes wrong go ahead and let this percolate; Jdbi will handle itpublic static <T> RowMapper<T> of(Class<T> type)
T - the type to maptype - the mapped typepublic static <T> RowMapper<T> of(Class<T> type, String prefix)
T - the type to maptype - the mapped typeprefix - the column name prefixpublic static <T> RowMapper<T> of(Constructor<T> constructor)
T - the type to mapconstructor - the constructor to be used in mappingpublic static <T> RowMapper<T> of(Constructor<T> constructor, String prefix)
T - the type to mapconstructor - the constructor to be used in mappingprefix - the column name prefixpublic RowMapper<T> specialize(ResultSet rs, StatementContext ctx) throws SQLException
RowMapperBefore 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.
specialize in interface RowMapper<T>rs - the result set to specialize overctx - the statement context to specialize overSQLException - if anything goes wrong go ahead and let this percolate; Jdbi will handle itfor an example of specialization.Copyright © 2017. All rights reserved.