use of org.jdbi.v3.core.qualifier.Qualifiers in project jdbi by jdbi.
the class QualifiersBenchmark method setup.
@Setup
public void setup() throws Throwable {
db = JdbiRule.h2();
db.before();
jdbi = db.getJdbi();
jdbi.registerRowMapper(BeanMapper.factory(UnqualifiedBean.class));
jdbi.registerRowMapper(BeanMapper.factory(QualifiedBean1.class));
jdbi.registerRowMapper(BeanMapper.factory(QualifiedBean2.class));
jdbi.registerRowMapper(BeanMapper.factory(QualifiedBean3.class));
jdbi.registerRowMapper(BeanMapper.factory(QualifiedBean4.class));
qualifiers = new Qualifiers();
qualifiers.setRegistry(new ConfigRegistry());
}
use of org.jdbi.v3.core.qualifier.Qualifiers in project jdbi by jdbi.
the class ResultReturner method forMethod.
/**
* Inspect a Method for its return type, and choose a ResultReturner subclass
* that handles any container that might wrap the results.
* @param extensionType the type that owns the Method
* @param method the method whose return type chooses the ResultReturner
* @return an instance that takes a ResultIterable and constructs the return value
*/
static ResultReturner forMethod(Class<?> extensionType, Method method) {
Type returnType = GenericTypes.resolveType(method.getGenericReturnType(), extensionType);
QualifiedType<?> qualifiedReturnType = QualifiedType.of(returnType).withAnnotations(new Qualifiers().findFor(method));
Class<?> returnClass = getErasedType(returnType);
if (Void.TYPE.equals(returnClass)) {
return findConsumer(method).orElseThrow(() -> new IllegalStateException(String.format("Method %s#%s is annotated as if it should return a value, but the method is void.", method.getDeclaringClass().getName(), method.getName())));
} else if (ResultIterable.class.equals(returnClass)) {
return new ResultIterableReturner(qualifiedReturnType);
} else if (Stream.class.equals(returnClass)) {
return new StreamReturner(qualifiedReturnType);
} else if (ResultIterator.class.equals(returnClass)) {
return new ResultIteratorReturner(qualifiedReturnType);
} else if (Iterator.class.equals(returnClass)) {
return new IteratorReturner(qualifiedReturnType);
} else if (method.isAnnotationPresent(SingleValue.class)) {
return new SingleValueReturner(qualifiedReturnType);
} else {
return new CollectedResultReturner(qualifiedReturnType);
}
}
use of org.jdbi.v3.core.qualifier.Qualifiers in project jdbi by jdbi.
the class ArgumentBinderTest method before.
@BeforeEach
public void before() {
when(ctx.getConfig(Qualifiers.class)).thenReturn(new Qualifiers());
when(ctx.getConfig(SqlStatements.class)).thenReturn(statements);
when(ctx.getConfig(Arguments.class)).thenReturn(new Arguments(new ConfigRegistry()));
}
Aggregations