Search in sources :

Example 21 with ConfigRegistry

use of org.jdbi.v3.core.config.ConfigRegistry in project jdbi by jdbi.

the class RegisterColumnMapperFactoryImpl method configureForType.

@Override
public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) {
    RegisterColumnMapperFactory registerColumnMapperFactory = (RegisterColumnMapperFactory) annotation;
    try {
        ColumnMapperFactory factory = registerColumnMapperFactory.value().newInstance();
        registry.get(ColumnMappers.class).register(factory);
    } catch (Exception e) {
        throw new IllegalStateException("unable to create a specified column mapper factory", e);
    }
}
Also used : ColumnMapperFactory(org.jdbi.v3.core.mapper.ColumnMapperFactory) RegisterColumnMapperFactory(org.jdbi.v3.sqlobject.config.RegisterColumnMapperFactory) RegisterColumnMapperFactory(org.jdbi.v3.sqlobject.config.RegisterColumnMapperFactory) ColumnMappers(org.jdbi.v3.core.mapper.ColumnMappers)

Example 22 with ConfigRegistry

use of org.jdbi.v3.core.config.ConfigRegistry 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 23 with ConfigRegistry

use of org.jdbi.v3.core.config.ConfigRegistry in project jdbi by jdbi.

the class RegisterFieldMappersImpl method configureForType.

@Override
public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) {
    Configurer delegate = new RegisterFieldMapperImpl();
    RegisterFieldMappers registerFieldMappers = (RegisterFieldMappers) annotation;
    Stream.of(registerFieldMappers.value()).forEach(anno -> delegate.configureForType(registry, anno, sqlObjectType));
}
Also used : RegisterFieldMappers(org.jdbi.v3.sqlobject.config.RegisterFieldMappers) Configurer(org.jdbi.v3.sqlobject.config.Configurer)

Example 24 with ConfigRegistry

use of org.jdbi.v3.core.config.ConfigRegistry in project jdbi by jdbi.

the class RegisterObjectArgumentFactoriesImpl method configureForType.

@Override
public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) {
    Configurer delegate = new RegisterObjectArgumentFactoryImpl();
    RegisterObjectArgumentFactories registerObjectArgumentFactories = (RegisterObjectArgumentFactories) annotation;
    Stream.of(registerObjectArgumentFactories.value()).forEach(anno -> delegate.configureForType(registry, anno, sqlObjectType));
}
Also used : RegisterObjectArgumentFactories(org.jdbi.v3.sqlobject.config.RegisterObjectArgumentFactories) Configurer(org.jdbi.v3.sqlobject.config.Configurer)

Example 25 with ConfigRegistry

use of org.jdbi.v3.core.config.ConfigRegistry in project jdbi by jdbi.

the class RegisterObjectArgumentFactoryImpl method configureForType.

@Override
public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) {
    RegisterObjectArgumentFactory registerObjectArgumentFactory = (RegisterObjectArgumentFactory) annotation;
    Arguments arguments = registry.get(Arguments.class);
    Class<?> clazz = registerObjectArgumentFactory.value();
    int sqlType = registerObjectArgumentFactory.sqlType();
    if (sqlType == Integer.MIN_VALUE) {
        arguments.register(ObjectArgumentFactory.create(clazz));
    } else {
        arguments.register(ObjectArgumentFactory.create(clazz, sqlType));
    }
}
Also used : Arguments(org.jdbi.v3.core.argument.Arguments) RegisterObjectArgumentFactory(org.jdbi.v3.sqlobject.config.RegisterObjectArgumentFactory)

Aggregations

Configurer (org.jdbi.v3.sqlobject.config.Configurer)10 ConfigRegistry (org.jdbi.v3.core.config.ConfigRegistry)8 RowMappers (org.jdbi.v3.core.mapper.RowMappers)5 SqlStatements (org.jdbi.v3.core.statement.SqlStatements)5 ColumnMappers (org.jdbi.v3.core.mapper.ColumnMappers)4 Type (java.lang.reflect.Type)3 Optional (java.util.Optional)3 ExtensionMethod (org.jdbi.v3.core.extension.ExtensionMethod)3 TemplateEngine (org.jdbi.v3.core.statement.TemplateEngine)3 Method (java.lang.reflect.Method)2 Types (java.sql.Types)2 Argument (org.jdbi.v3.core.argument.Argument)2 Arguments (org.jdbi.v3.core.argument.Arguments)2 JdbiCollectors (org.jdbi.v3.core.collector.JdbiCollectors)2 GenericTypes (org.jdbi.v3.core.generic.GenericTypes)2 ColumnMapperFactory (org.jdbi.v3.core.mapper.ColumnMapperFactory)2 MapEntryMappers (org.jdbi.v3.core.mapper.MapEntryMappers)2 SqlParser (org.jdbi.v3.core.statement.SqlParser)2 UseSqlParser (org.jdbi.v3.sqlobject.config.UseSqlParser)2 UseTemplateEngine (org.jdbi.v3.sqlobject.config.UseTemplateEngine)2