/** * Returns a mapper for the given bean class * * @param <T> the type to find the mapper for * @param type the mapped class * @return a mapper for the given bean class */ public static <T> RowMapper<T> of(Class<T> type) { return BeanMapper.of(type, DEFAULT_PREFIX); }
/** * Returns a mapper factory that maps to the given bean class * * @param type the mapped class * @return a mapper factory that maps to the given bean class */ public static RowMapperFactory factory(Class<?> type) { return RowMapperFactory.of(type, BeanMapper.of(type)); }
/** * Maps this result set to a {@link ResultIterable} of the given element type, using {@link BeanMapper}. * * @param type the bean type to map the result set rows to * @param <T> the bean type to map the result set rows to * @return a {@link ResultIterable} of the given type. */ @SuppressWarnings("deprecation") default <T> ResultIterable<T> mapToBean(Class<T> type) { return map(BeanMapper.of(type)); }
/** * Returns a mapper factory that maps to the given bean class * * @param type the mapped class * @param prefix the column name prefix for each mapped bean property * @return a mapper factory that maps to the given bean class */ public static RowMapperFactory factory(Class<?> type, String prefix) { return RowMapperFactory.of(type, BeanMapper.of(type, prefix)); }
@Test public void shouldSetValuesInSuperClassProperties() throws Exception { mockColumns("longField", "blongField"); Long aLongVal = 100L; Long bLongVal = 200L; when(resultSet.getLong(1)).thenReturn(aLongVal); when(resultSet.getLong(2)).thenReturn(bLongVal); when(resultSet.wasNull()).thenReturn(false); RowMapper<DerivedBean> mapper = BeanMapper.of(DerivedBean.class); DerivedBean derivedBean = mapper.map(resultSet, ctx); assertThat(derivedBean.getLongField()).isEqualTo(aLongVal); assertThat(derivedBean.getBlongField()).isEqualTo(bLongVal); }
/** * Returns a mapper for the given bean class * * @param <T> the type to find the mapper for * @param type the mapped class * @return a mapper for the given bean class */ public static <T> RowMapper<T> of(Class<T> type) { return BeanMapper.of(type, DEFAULT_PREFIX); }
/** * Returns a mapper factory that maps to the given bean class * * @param type the mapped class * @return a mapper factory that maps to the given bean class */ public static RowMapperFactory factory(Class<?> type) { return RowMapperFactory.of(type, BeanMapper.of(type)); }
/** * Returns a mapper factory that maps to the given bean class * * @param type the mapped class * @param prefix the column name prefix for each mapped bean property * @return a mapper factory that maps to the given bean class */ public static RowMapperFactory factory(Class<?> type, String prefix) { return RowMapperFactory.of(type, BeanMapper.of(type, prefix)); }
/** * Maps this result set to a {@link ResultIterable} of the given element type, using {@link BeanMapper}. * * @param type the bean type to map the result set rows to * @param <T> the bean type to map the result set rows to * @return a {@link ResultIterable} of the given type. */ default <T> ResultIterable<T> mapToBean(Class<T> type) { return map(BeanMapper.of(type)); }