Search in sources :

Example 6 with Interface

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;
}
Also used : CompilationUnit(org.mybatis.generator.api.dom.java.CompilationUnit) ArrayList(java.util.ArrayList) Interface(org.mybatis.generator.api.dom.java.Interface)

Example 7 with Interface

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;
}
Also used : CompilationUnit(org.mybatis.generator.api.dom.java.CompilationUnit) CommentGenerator(org.mybatis.generator.api.CommentGenerator) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) ArrayList(java.util.ArrayList) Messages.getString(org.mybatis.generator.internal.util.messages.Messages.getString) Interface(org.mybatis.generator.api.dom.java.Interface)

Example 8 with Interface

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;
}
Also used : CompilationUnit(org.mybatis.generator.api.dom.java.CompilationUnit) FullyQualifiedTable(org.mybatis.generator.api.FullyQualifiedTable) TopLevelClass(org.mybatis.generator.api.dom.java.TopLevelClass) ArrayList(java.util.ArrayList) Interface(org.mybatis.generator.api.dom.java.Interface)

Example 9 with Interface

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;
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Messages.getString(org.mybatis.generator.internal.util.messages.Messages.getString) Interface(org.mybatis.generator.api.dom.java.Interface)

Example 10 with Interface

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();
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method) Interface(org.mybatis.generator.api.dom.java.Interface)

Aggregations

Interface (org.mybatis.generator.api.dom.java.Interface)13 FullyQualifiedJavaType (org.mybatis.generator.api.dom.java.FullyQualifiedJavaType)10 ArrayList (java.util.ArrayList)5 CompilationUnit (org.mybatis.generator.api.dom.java.CompilationUnit)5 Messages.getString (org.mybatis.generator.internal.util.messages.Messages.getString)3 Test (org.junit.Test)2 CommentGenerator (org.mybatis.generator.api.CommentGenerator)2 DefaultJavaFormatter (org.mybatis.generator.api.dom.DefaultJavaFormatter)2 Method (org.mybatis.generator.api.dom.java.Method)2 Parameter (org.mybatis.generator.api.dom.java.Parameter)2 TopLevelClass (org.mybatis.generator.api.dom.java.TopLevelClass)2 FullyQualifiedTable (org.mybatis.generator.api.FullyQualifiedTable)1