Search in sources :

Example 1 with RowMappers

use of org.jdbi.v3.core.mapper.RowMappers in project jdbi by jdbi.

the class RegisterConstructorMapperImpl method configureForType.

@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));
    }
}
Also used : RegisterConstructorMapper(org.jdbi.v3.sqlobject.config.RegisterConstructorMapper) RowMappers(org.jdbi.v3.core.mapper.RowMappers)

Example 2 with RowMappers

use of org.jdbi.v3.core.mapper.RowMappers in project jdbi by jdbi.

the class RegisterRowMapperFactoryImpl method configureForType.

@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);
    }
}
Also used : RowMappers(org.jdbi.v3.core.mapper.RowMappers) RegisterRowMapperFactory(org.jdbi.v3.sqlobject.config.RegisterRowMapperFactory)

Example 3 with RowMappers

use of org.jdbi.v3.core.mapper.RowMappers in project jdbi by jdbi.

the class RegisterFieldMapperImpl method configureForType.

@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));
    }
}
Also used : RegisterFieldMapper(org.jdbi.v3.sqlobject.config.RegisterFieldMapper) RowMappers(org.jdbi.v3.core.mapper.RowMappers)

Example 4 with RowMappers

use of org.jdbi.v3.core.mapper.RowMappers in project jdbi by jdbi.

the class RegisterBeanMapperImpl method configureForType.

@Override
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));
    }
}
Also used : RowMappers(org.jdbi.v3.core.mapper.RowMappers) RegisterBeanMapper(org.jdbi.v3.sqlobject.config.RegisterBeanMapper)

Aggregations

RowMappers (org.jdbi.v3.core.mapper.RowMappers)4 RegisterBeanMapper (org.jdbi.v3.sqlobject.config.RegisterBeanMapper)1 RegisterConstructorMapper (org.jdbi.v3.sqlobject.config.RegisterConstructorMapper)1 RegisterFieldMapper (org.jdbi.v3.sqlobject.config.RegisterFieldMapper)1 RegisterRowMapperFactory (org.jdbi.v3.sqlobject.config.RegisterRowMapperFactory)1