use of org.mybatis.generator.api.dom.java.Interface in project generator by mybatis.
the class SimpleInterfaceGenerator method generate.
@Override
public List<CompilationUnit> generate() {
List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
Interface interfaze = generateInterface();
answer.add(interfaze);
answer.add(generateClass(interfaze));
return answer;
}
use of org.mybatis.generator.api.dom.java.Interface in project generator by mybatis.
the class JavaMapperGenerator 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);
}
addCountByExampleMethod(interfaze);
addDeleteByExampleMethod(interfaze);
addDeleteByPrimaryKeyMethod(interfaze);
addInsertMethod(interfaze);
addInsertSelectiveMethod(interfaze);
addSelectByExampleWithBLOBsMethod(interfaze);
addSelectByExampleWithoutBLOBsMethod(interfaze);
addSelectByPrimaryKeyMethod(interfaze);
addUpdateByExampleSelectiveMethod(interfaze);
addUpdateByExampleWithBLOBsMethod(interfaze);
addUpdateByExampleWithoutBLOBsMethod(interfaze);
addUpdateByPrimaryKeySelectiveMethod(interfaze);
addUpdateByPrimaryKeyWithBLOBsMethod(interfaze);
addUpdateByPrimaryKeyWithoutBLOBsMethod(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 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;
}
use of org.mybatis.generator.api.dom.java.Interface in project generator by mybatis.
the class DAOGenerator method getInterfaceShell.
protected Interface getInterfaceShell() {
Interface answer = new Interface(new FullyQualifiedJavaType(introspectedTable.getDAOInterfaceType()));
answer.setVisibility(JavaVisibility.PUBLIC);
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);
answer.addSuperInterface(fqjt);
answer.addImportedType(fqjt);
}
for (FullyQualifiedJavaType fqjt : daoTemplate.getInterfaceImports()) {
answer.addImportedType(fqjt);
}
context.getCommentGenerator().addJavaFileComment(answer);
return answer;
}
use of org.mybatis.generator.api.dom.java.Interface in project generator by mybatis.
the class TestResourceGenerator method simpleInterfaceWithGeneratedAndCustomItems.
public static String simpleInterfaceWithGeneratedAndCustomItems() {
Interface itf = new Interface(new FullyQualifiedJavaType("org.mybatis.test.SimpleInterface"));
itf.setVisibility(JavaVisibility.PUBLIC);
Method method = new Method("subtract");
method.addParameter(new Parameter(FullyQualifiedJavaType.getIntInstance(), "a"));
method.addParameter(new Parameter(FullyQualifiedJavaType.getIntInstance(), "b"));
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
commentGenerator.addMethodComment(method);
itf.addMethod(method);
method = new Method("nonGeneratedMethod");
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
itf.addMethod(method);
return itf.getFormattedContent();
}
Aggregations