enhanced.mybaits.generator.EnhanceIntrospectedTableMyBatis3SimpleImpl Maven / Gradle / Ivy
package enhanced.mybaits.generator;
import enhanced.mybaits.generator.codegen.EnhanceSimpleJavaClientGenerator;
import enhanced.mybaits.generator.codegen.EnhanceSimpleXMLMapperGenerator;
import org.mybatis.generator.api.ProgressCallback;
import org.mybatis.generator.codegen.AbstractJavaClientGenerator;
import org.mybatis.generator.codegen.mybatis3.IntrospectedTableMyBatis3SimpleImpl;
import org.mybatis.generator.codegen.mybatis3.javamapper.SimpleAnnotatedClientGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.SimpleJavaClientGenerator;
import org.mybatis.generator.internal.ObjectFactory;
import java.util.List;
/**
* My baits 生成器 代码生成类
*
* @author 徐明龙 XuMingLong
*/
public class EnhanceIntrospectedTableMyBatis3SimpleImpl extends IntrospectedTableMyBatis3SimpleImpl {
/**
* 选择XML Mapper生成器
*
* @author 徐明龙 XuMingLong
* @param javaClientGenerator 对应的JavaClient生成器
* @param warnings 额外的参数
* @param progressCallback 处理进展通知回调类
*/
@Override
protected void calculateXmlMapperGenerator(AbstractJavaClientGenerator javaClientGenerator, List warnings,
ProgressCallback progressCallback) {
if (javaClientGenerator == null) {
if (context.getSqlMapGeneratorConfiguration() != null) {
xmlMapperGenerator = new EnhanceSimpleXMLMapperGenerator();
}
} else {
xmlMapperGenerator = javaClientGenerator.getMatchedXMLGenerator();
}
initializeAbstractGenerator(xmlMapperGenerator, warnings, progressCallback);
super.calculateXmlMapperGenerator(javaClientGenerator, warnings, progressCallback);
}
/**
* 选择Java Client生成器
*
* @author 徐明龙 XuMingLong
* @return Java Client生成器
*/
@Override
protected AbstractJavaClientGenerator createJavaClientGenerator() {
if (context.getJavaClientGeneratorConfiguration() == null) {
return null;
}
String type = context.getJavaClientGeneratorConfiguration().getConfigurationType();
AbstractJavaClientGenerator javaGenerator;
if ("XMLMAPPER".equalsIgnoreCase(type)) {
javaGenerator = new EnhanceSimpleJavaClientGenerator(this.getClientProject());
} else if ("ANNOTATEDMAPPER".equalsIgnoreCase(type)) {
javaGenerator = new SimpleAnnotatedClientGenerator(this.getClientProject());
} else if ("MAPPER".equalsIgnoreCase(type)) {
javaGenerator = new SimpleJavaClientGenerator(this.getClientProject());
} else {
javaGenerator = (AbstractJavaClientGenerator)ObjectFactory.createInternalObject(type);
}
return javaGenerator;
}
}