/** * Register a row mapper for a given type. * * @param type the type to match with equals. * @param mapper the row mapper * @return this */ public RowMappers register(Type type, RowMapper<?> mapper) { return this.register(RowMapperFactory.of(type, mapper)); }
/** * Convenience method for {@code getConfig(RowMappers.class).register(type, mapper)} * * @param <T> the type * @param type to match * @param mapper row mapper * @return this */ default <T> This registerRowMapper(GenericType<T> type, RowMapper<T> mapper) { return configure(RowMappers.class, c -> c.register(type, mapper)); }
/** * Convenience method for {@code getConfig(RowMappers.class).register(mapper)} * * @param mapper row mapper * @return this */ default This registerRowMapper(RowMapper<?> mapper) { return configure(RowMappers.class, c -> c.register(mapper)); }
/** * Convenience method for {@code getConfig(RowMappers.class).register(type, mapper)} * * @param type to match * @param mapper row mapper * @return this */ default This registerRowMapper(Type type, RowMapper<?> mapper) { return configure(RowMappers.class, c -> c.register(type, mapper)); }
/** * Convenience method for {@code getConfig(RowMappers.class).register(factory)} * * @param factory row mapper factory * @return this */ default This registerRowMapper(RowMapperFactory factory) { return configure(RowMappers.class, c -> c.register(factory)); } }
/** * Register a row mapper which will have its parameterized type inspected to determine what it maps to. * Will be used with {@link Query#mapTo(Class)} for registered mappings. * <p> * The parameter must be concretely parameterized, we use the type argument T to * determine if it applies to a given type. * * @param mapper the row mapper * @return this * @throws UnsupportedOperationException if the RowMapper is not a concretely parameterized type */ public RowMappers register(RowMapper<?> mapper) { return this.register(new InferredRowMapperFactory(mapper)); }
@Override public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) { RegisterRowMapper registerRowMapper = (RegisterRowMapper) annotation; try { registry.get(RowMappers.class).register(registerRowMapper.value().newInstance()); } catch (Exception e) { throw new IllegalStateException("unable to create a specified row mapper", e); } } }
@Override public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) { RegisterRowMapperFactory registerRowMapperFactory = (RegisterRowMapperFactory) annotation; RowMappers mappers = registry.get(RowMappers.class); try { mappers.register(registerRowMapperFactory.value().newInstance()); } catch (Exception e) { throw new IllegalStateException("unable to create a specified row mapper factory", e); } } }
/** * Register a row mapper for a given type. * * @param <T> the type * @param type the type to match with equals. * @param mapper the row mapper * @return this */ public <T> RowMappers register(GenericType<T> type, RowMapper<T> mapper) { return this.register(RowMapperFactory.of(type.getType(), mapper)); }
@Override @SuppressWarnings("deprecation") public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) { RegisterBeanMapper registerBeanMapper = (RegisterBeanMapper) annotation; Class<?> beanClass = registerBeanMapper.value(); String prefix = registerBeanMapper.prefix(); RowMappers mappers = registry.get(RowMappers.class); if (prefix.isEmpty()) { mappers.register(BeanMapper.factory(beanClass)); } else { mappers.register(BeanMapper.factory(beanClass, prefix)); } }
@Override public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) { RegisterFieldMapper registerFieldMapper = (RegisterFieldMapper) annotation; Class<?> type = registerFieldMapper.value(); String prefix = registerFieldMapper.prefix(); RowMappers mappers = registry.get(RowMappers.class); if (prefix.isEmpty()) { mappers.register(FieldMapper.factory(type)); } else { mappers.register(FieldMapper.factory(type, prefix)); } }
@Override public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) { RegisterConstructorMapper registerConstructorMapper = (RegisterConstructorMapper) annotation; RowMappers mappers = registry.get(RowMappers.class); Class<?> type = registerConstructorMapper.value(); String prefix = registerConstructorMapper.prefix(); if (prefix.isEmpty()) { mappers.register(ConstructorMapper.factory(type)); } else { mappers.register(ConstructorMapper.factory(type, prefix)); } } }
@Override public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) { RegisterJoinRowMapper registerJoinRowMapper = (RegisterJoinRowMapper) annotation; registry.get(RowMappers.class).register(JoinRowMapper.forTypes(registerJoinRowMapper.value())); } }
/** * Convenience method for {@code getConfig(RowMappers.class).register(type, mapper)} * * @param type to match * @param mapper row mapper * @return this */ default This registerRowMapper(Type type, RowMapper<?> mapper) { return configure(RowMappers.class, c -> c.register(type, mapper)); }
/** * Convenience method for {@code getConfig(RowMappers.class).register(factory)} * * @param factory row mapper factory * @return this */ default This registerRowMapper(RowMapperFactory factory) { return configure(RowMappers.class, c -> c.register(factory)); } }
/** * Register a row mapper for a given type. * * @param type the type to match with equals. * @param mapper the row mapper * @return this */ public RowMappers register(Type type, RowMapper<?> mapper) { return this.register(RowMapperFactory.of(type, mapper)); }
/** * Convenience method for {@code getConfig(RowMappers.class).register(mapper)} * * @param mapper row mapper * @return this */ default This registerRowMapper(RowMapper<?> mapper) { return configure(RowMappers.class, c -> c.register(mapper)); }
public RowMappers() { register(MapEntryMapper.factory()); }
/** * Register a row mapper which will have its parameterized type inspected to determine what it maps to. * Will be used with {@link Query#mapTo(Class)} for registered mappings. * <p> * The parameter must be concretely parameterized, we use the type argument T to * determine if it applies to a given type. * * @param mapper the row mapper * @return this * @throws UnsupportedOperationException if the RowMapper is not a concretely parameterized type */ public RowMappers register(RowMapper<?> mapper) { return this.register(new InferredRowMapperFactory(mapper)); }