use of org.mybatis.generator.api.dom.java.TopLevelClass 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.TopLevelClass in project generator by mybatis.
the class SupersGenerator method getBaseClass.
private TopLevelClass getBaseClass() {
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(BASE_PACKAGE + ".BaseClass");
TopLevelClass tlc = new TopLevelClass(fqjt);
tlc.setVisibility(JavaVisibility.PUBLIC);
return tlc;
}
use of org.mybatis.generator.api.dom.java.TopLevelClass in project generator by mybatis.
the class Test1Generator method generate.
public List<CompilationUnit> generate() {
FullyQualifiedJavaType cls = new FullyQualifiedJavaType(BASE_PACKAGE + ".SomeClass");
List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
TopLevelClass tlcMain = generateFieldTypeMain();
TopLevelClass tlcSub1 = generateFieldTypeSub1();
TopLevelClass tlcTcSub1 = generateTestClassSub1();
TopLevelClass tlcSub2 = generateFieldTypeSub2();
answer.add(tlcMain);
answer.add(tlcSub1);
answer.add(tlcTcSub1);
answer.add(tlcSub2);
TopLevelClass topLvlClass = new TopLevelClass(cls);
topLvlClass.setVisibility(JavaVisibility.PUBLIC);
topLvlClass.addImportedType(tlcTcSub1.getType());
Field field = new Field("main", tlcMain.getType());
field.setVisibility(JavaVisibility.PRIVATE);
topLvlClass.addField(field);
field = new Field("tcSub1", tlcTcSub1.getType());
field.setVisibility(JavaVisibility.PRIVATE);
topLvlClass.addField(field);
field = new Field("sub1", tlcSub1.getType());
field.setVisibility(JavaVisibility.PRIVATE);
topLvlClass.addField(field);
field = new Field("sub2", tlcSub2.getType());
field.setVisibility(JavaVisibility.PRIVATE);
topLvlClass.addField(field);
Method m = new Method();
m.setVisibility(JavaVisibility.PUBLIC);
m.setName("executeMain");
m.addBodyLine("main.mainMethod();");
topLvlClass.addMethod(m);
m = new Method();
m.setVisibility(JavaVisibility.PUBLIC);
m.setName("setMain");
m.addParameter(new Parameter(tlcMain.getType(), "main"));
m.addBodyLine("this.main = main;");
topLvlClass.addMethod(m);
m = new Method();
m.setVisibility(JavaVisibility.PUBLIC);
m.setName("getMain");
m.setReturnType(tlcMain.getType());
m.addBodyLine("return main;");
topLvlClass.addMethod(m);
m = new Method();
m.setVisibility(JavaVisibility.PUBLIC);
m.setName("executeSub1");
m.addBodyLine("sub1.sub1Method();");
topLvlClass.addMethod(m);
m = new Method();
m.setVisibility(JavaVisibility.PUBLIC);
m.setName("setSub1");
m.addParameter(new Parameter(tlcSub1.getType(), "sub1"));
m.addBodyLine("this.sub1 = sub1;");
topLvlClass.addMethod(m);
m = new Method();
m.setVisibility(JavaVisibility.PUBLIC);
m.setName("getSub1");
m.setReturnType(tlcSub1.getType());
m.addBodyLine("return sub1;");
topLvlClass.addMethod(m);
m = new Method();
m.setVisibility(JavaVisibility.PUBLIC);
m.setName("executeSub2");
m.addBodyLine("sub2.sub2Method();");
topLvlClass.addMethod(m);
m = new Method();
m.setVisibility(JavaVisibility.PUBLIC);
m.setName("setSub2");
m.addParameter(new Parameter(tlcSub2.getType(), "sub2"));
m.addBodyLine("this.sub2 = sub2;");
topLvlClass.addMethod(m);
m = new Method();
m.setVisibility(JavaVisibility.PUBLIC);
m.setName("getSub2");
m.setReturnType(tlcSub2.getType());
m.addBodyLine("return sub2;");
topLvlClass.addMethod(m);
answer.add(topLvlClass);
return answer;
}
use of org.mybatis.generator.api.dom.java.TopLevelClass in project generator by mybatis.
the class SimpleInterfaceGenerator method generateClass.
private TopLevelClass generateClass(Interface interfaze) {
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(BASE_PACKAGE + "SimpleClass");
TopLevelClass tlc = new TopLevelClass(fqjt);
tlc.setVisibility(JavaVisibility.PUBLIC);
tlc.addSuperInterface(interfaze.getType());
tlc.addImportedType(interfaze.getType());
return tlc;
}
use of org.mybatis.generator.api.dom.java.TopLevelClass in project generator by mybatis.
the class DAOGenerator method getCompilationUnits.
@Override
public List<CompilationUnit> getCompilationUnits() {
FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
progressCallback.startTask(getString("Progress.14", //$NON-NLS-1$
table.toString()));
TopLevelClass topLevelClass = getTopLevelClassShell();
Interface interfaze = getInterfaceShell();
addCountByExampleMethod(topLevelClass, interfaze);
addDeleteByExampleMethod(topLevelClass, interfaze);
addDeleteByPrimaryKeyMethod(topLevelClass, interfaze);
addInsertMethod(topLevelClass, interfaze);
addInsertSelectiveMethod(topLevelClass, interfaze);
addSelectByExampleWithBLOBsMethod(topLevelClass, interfaze);
addSelectByExampleWithoutBLOBsMethod(topLevelClass, interfaze);
addSelectByPrimaryKeyMethod(topLevelClass, interfaze);
addUpdateByExampleParmsInnerclass(topLevelClass, interfaze);
addUpdateByExampleSelectiveMethod(topLevelClass, interfaze);
addUpdateByExampleWithBLOBsMethod(topLevelClass, interfaze);
addUpdateByExampleWithoutBLOBsMethod(topLevelClass, interfaze);
addUpdateByPrimaryKeySelectiveMethod(topLevelClass, interfaze);
addUpdateByPrimaryKeyWithBLOBsMethod(topLevelClass, interfaze);
addUpdateByPrimaryKeyWithoutBLOBsMethod(topLevelClass, interfaze);
List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
if (context.getPlugins().clientGenerated(interfaze, topLevelClass, introspectedTable)) {
answer.add(topLevelClass);
answer.add(interfaze);
}
return answer;
}
Aggregations