org.xblackcat.sjpu.storage.impl.AMappableMethodBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sjpu-dbah Show documentation
Show all versions of sjpu-dbah Show documentation
Service for generating DB access logic in simple way via interfaces and annotations
package org.xblackcat.sjpu.storage.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xblackcat.sjpu.skel.IMethodBuilder;
import org.xblackcat.sjpu.storage.consumer.IRowSetConsumer;
import org.xblackcat.sjpu.storage.typemap.TypeMapper;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Map;
/**
* 19.12.13 16:50
*
* @author xBlackCat
*/
public abstract class AMappableMethodBuilder implements IMethodBuilder {
protected final Log log = LogFactory.getLog(getClass());
protected final TypeMapper typeMapper;
protected final Map, Class extends IRowSetConsumer>> rowSetConsumers;
private final Class annClass;
public AMappableMethodBuilder(
Class annClass,
TypeMapper typeMapper,
Map, Class extends IRowSetConsumer>> rowSetConsumers
) {
this.typeMapper = typeMapper;
this.rowSetConsumers = rowSetConsumers;
this.annClass = annClass;
}
protected Class extends IRowSetConsumer> hasRowSetConsumer(Class> returnType, Class> realReturnType) {
for (Map.Entry, Class extends IRowSetConsumer>> e : rowSetConsumers.entrySet()) {
if (returnType.equals(e.getKey()) && !realReturnType.isAssignableFrom(e.getKey())) {
return e.getValue();
}
}
return null;
}
@Override
public Class getAnnotationClass() {
return annClass;
}
protected A getAnnotation(Method m) {
return m.getAnnotation(getAnnotationClass());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy