use of org.mybatis.generator.api.dom.java.Interface in project generator by mybatis.
the class TestResourceGenerator method simpleInterfaceWithAllGeneratedItems.
public static String simpleInterfaceWithAllGeneratedItems() {
Interface itf = new Interface(new FullyQualifiedJavaType("org.mybatis.test.SimpleInterface"));
itf.setVisibility(JavaVisibility.PUBLIC);
Method method = new Method("count");
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
commentGenerator.addMethodComment(method);
itf.addMethod(method);
method = new Method("add");
method.addParameter(new Parameter(FullyQualifiedJavaType.getIntInstance(), "a"));
method.addParameter(new Parameter(FullyQualifiedJavaType.getIntInstance(), "b"));
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
commentGenerator.addMethodComment(method);
itf.addMethod(method);
return itf.getFormattedContent();
}
use of org.mybatis.generator.api.dom.java.Interface in project generator by mybatis.
the class SimpleJavaClientGenerator method getCompilationUnits.
@Override
public List<CompilationUnit> getCompilationUnits() {
progressCallback.startTask(getString(//$NON-NLS-1$
"Progress.17", introspectedTable.getFullyQualifiedTable().toString()));
CommentGenerator commentGenerator = context.getCommentGenerator();
FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getMyBatis3JavaMapperType());
Interface interfaze = new Interface(type);
interfaze.setVisibility(JavaVisibility.PUBLIC);
commentGenerator.addJavaFileComment(interfaze);
String rootInterface = introspectedTable.getTableConfigurationProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
if (!stringHasValue(rootInterface)) {
rootInterface = context.getJavaClientGeneratorConfiguration().getProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
}
if (stringHasValue(rootInterface)) {
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(rootInterface);
interfaze.addSuperInterface(fqjt);
interfaze.addImportedType(fqjt);
}
addDeleteByPrimaryKeyMethod(interfaze);
addInsertMethod(interfaze);
addSelectByPrimaryKeyMethod(interfaze);
addSelectAllMethod(interfaze);
addUpdateByPrimaryKeyMethod(interfaze);
List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
if (context.getPlugins().clientGenerated(interfaze, null, introspectedTable)) {
answer.add(interfaze);
}
List<CompilationUnit> extraCompilationUnits = getExtraCompilationUnits();
if (extraCompilationUnits != null) {
answer.addAll(extraCompilationUnits);
}
return answer;
}
use of org.mybatis.generator.api.dom.java.Interface in project generator by mybatis.
the class SupersGenerator method getBaseInterface.
private Interface getBaseInterface() {
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(BASE_PACKAGE + ".BaseInterface");
Interface ifc = new Interface(fqjt);
ifc.setVisibility(JavaVisibility.PUBLIC);
return ifc;
}
use of org.mybatis.generator.api.dom.java.Interface in project generator by mybatis.
the class SupersGenerator method generate.
@Override
public List<CompilationUnit> generate() {
List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
TopLevelClass baseClass = getBaseClass();
TopLevelClass superClass = getSuperClass();
baseClass.setSuperClass(superClass.getType());
Interface baseInterface = getBaseInterface();
Interface superInterface = getSuperInterface();
baseInterface.addSuperInterface(superInterface.getType());
baseClass.addSuperInterface(superInterface.getType());
answer.add(baseClass);
answer.add(superClass);
answer.add(baseInterface);
answer.add(superInterface);
return answer;
}
use of org.mybatis.generator.api.dom.java.Interface in project generator by mybatis.
the class SupersGenerator method getSuperInterface.
private Interface getSuperInterface() {
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(BASE_PACKAGE + ".sub.SuperInterface");
Interface ifc = new Interface(fqjt);
ifc.setVisibility(JavaVisibility.PUBLIC);
return ifc;
}
Aggregations