Search in sources :

Example 51 with Parameter

use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.

the class InsertSelectiveMethodGenerator method addInterfaceElements.

@Override
public void addInterfaceElements(Interface interfaze) {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    Method method = new Method();
    method.setReturnType(FullyQualifiedJavaType.getIntInstance());
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName(introspectedTable.getInsertSelectiveStatementId());
    FullyQualifiedJavaType parameterType = introspectedTable.getRules().calculateAllFieldsClass();
    importedTypes.add(parameterType);
    //$NON-NLS-1$
    method.addParameter(new Parameter(parameterType, "record"));
    context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable);
    addMapperAnnotations(method);
    if (context.getPlugins().clientInsertSelectiveMethodGenerated(method, interfaze, introspectedTable)) {
        addExtraImports(interfaze);
        interfaze.addImportedTypes(importedTypes);
        interfaze.addMethod(method);
    }
}
Also used : TreeSet(java.util.TreeSet) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

Example 52 with Parameter

use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.

the class SelectByExampleWithBLOBsMethodGenerator method addInterfaceElements.

@Override
public void addInterfaceElements(Interface interfaze) {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getExampleType());
    importedTypes.add(type);
    importedTypes.add(FullyQualifiedJavaType.getNewListInstance());
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    FullyQualifiedJavaType returnType = FullyQualifiedJavaType.getNewListInstance();
    FullyQualifiedJavaType listType;
    if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
        listType = new FullyQualifiedJavaType(introspectedTable.getRecordWithBLOBsType());
    } else {
        // the blob fields must be rolled up into the base class
        listType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
    }
    importedTypes.add(listType);
    returnType.addTypeArgument(listType);
    method.setReturnType(returnType);
    method.setName(introspectedTable.getSelectByExampleWithBLOBsStatementId());
    //$NON-NLS-1$
    method.addParameter(new Parameter(type, "example"));
    context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable);
    addMapperAnnotations(interfaze, method);
    if (context.getPlugins().clientSelectByExampleWithBLOBsMethodGenerated(method, interfaze, introspectedTable)) {
        addExtraImports(interfaze);
        interfaze.addImportedTypes(importedTypes);
        interfaze.addMethod(method);
    }
}
Also used : TreeSet(java.util.TreeSet) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

Example 53 with Parameter

use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.

the class UpdateByExampleSelectiveMethodGenerator method addInterfaceElements.

@Override
public void addInterfaceElements(Interface interfaze) {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setReturnType(FullyQualifiedJavaType.getIntInstance());
    method.setName(introspectedTable.getUpdateByExampleSelectiveStatementId());
    FullyQualifiedJavaType parameterType = introspectedTable.getRules().calculateAllFieldsClass();
    method.addParameter(new Parameter(parameterType, "record", //$NON-NLS-1$ //$NON-NLS-2$
    "@Param(\"record\")"));
    importedTypes.add(parameterType);
    FullyQualifiedJavaType exampleType = new FullyQualifiedJavaType(introspectedTable.getExampleType());
    method.addParameter(new Parameter(exampleType, "example", //$NON-NLS-1$ //$NON-NLS-2$
    "@Param(\"example\")"));
    importedTypes.add(exampleType);
    importedTypes.add(new FullyQualifiedJavaType(//$NON-NLS-1$
    "org.apache.ibatis.annotations.Param"));
    context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable);
    addMapperAnnotations(method);
    if (context.getPlugins().clientUpdateByExampleSelectiveMethodGenerated(method, interfaze, introspectedTable)) {
        addExtraImports(interfaze);
        interfaze.addImportedTypes(importedTypes);
        interfaze.addMethod(method);
    }
}
Also used : TreeSet(java.util.TreeSet) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

Example 54 with Parameter

use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.

the class UpdateByExampleWithBLOBsMethodGenerator method addInterfaceElements.

@Override
public void addInterfaceElements(Interface interfaze) {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setReturnType(FullyQualifiedJavaType.getIntInstance());
    method.setName(introspectedTable.getUpdateByExampleWithBLOBsStatementId());
    FullyQualifiedJavaType parameterType;
    if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
        parameterType = new FullyQualifiedJavaType(introspectedTable.getRecordWithBLOBsType());
    } else {
        parameterType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
    }
    method.addParameter(new Parameter(parameterType, "record", //$NON-NLS-1$ //$NON-NLS-2$
    "@Param(\"record\")"));
    importedTypes.add(parameterType);
    FullyQualifiedJavaType exampleType = new FullyQualifiedJavaType(introspectedTable.getExampleType());
    method.addParameter(new Parameter(exampleType, "example", //$NON-NLS-1$ //$NON-NLS-2$
    "@Param(\"example\")"));
    importedTypes.add(exampleType);
    importedTypes.add(new FullyQualifiedJavaType(//$NON-NLS-1$
    "org.apache.ibatis.annotations.Param"));
    context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable);
    addMapperAnnotations(method);
    if (context.getPlugins().clientUpdateByExampleWithBLOBsMethodGenerated(method, interfaze, introspectedTable)) {
        addExtraImports(interfaze);
        interfaze.addImportedTypes(importedTypes);
        interfaze.addMethod(method);
    }
}
Also used : TreeSet(java.util.TreeSet) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

Example 55 with Parameter

use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.

the class UpdateByExampleWithoutBLOBsMethodGenerator method addInterfaceElements.

@Override
public void addInterfaceElements(Interface interfaze) {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setReturnType(FullyQualifiedJavaType.getIntInstance());
    method.setName(introspectedTable.getUpdateByExampleStatementId());
    FullyQualifiedJavaType parameterType;
    if (introspectedTable.getRules().generateBaseRecordClass()) {
        parameterType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
    } else {
        parameterType = new FullyQualifiedJavaType(introspectedTable.getPrimaryKeyType());
    }
    method.addParameter(new Parameter(parameterType, "record", //$NON-NLS-1$ //$NON-NLS-2$
    "@Param(\"record\")"));
    importedTypes.add(parameterType);
    FullyQualifiedJavaType exampleType = new FullyQualifiedJavaType(introspectedTable.getExampleType());
    method.addParameter(new Parameter(exampleType, "example", //$NON-NLS-1$ //$NON-NLS-2$
    "@Param(\"example\")"));
    importedTypes.add(exampleType);
    importedTypes.add(new FullyQualifiedJavaType(//$NON-NLS-1$
    "org.apache.ibatis.annotations.Param"));
    context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable);
    addMapperAnnotations(method);
    if (context.getPlugins().clientUpdateByExampleWithoutBLOBsMethodGenerated(method, interfaze, introspectedTable)) {
        addExtraImports(interfaze);
        interfaze.addImportedTypes(importedTypes);
        interfaze.addMethod(method);
    }
}
Also used : TreeSet(java.util.TreeSet) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

Aggregations

Parameter (org.mybatis.generator.api.dom.java.Parameter)68 Method (org.mybatis.generator.api.dom.java.Method)66 FullyQualifiedJavaType (org.mybatis.generator.api.dom.java.FullyQualifiedJavaType)55 TreeSet (java.util.TreeSet)20 IntrospectedColumn (org.mybatis.generator.api.IntrospectedColumn)17 Field (org.mybatis.generator.api.dom.java.Field)11 ArrayList (java.util.ArrayList)7 InnerClass (org.mybatis.generator.api.dom.java.InnerClass)5 TopLevelClass (org.mybatis.generator.api.dom.java.TopLevelClass)5 Messages.getString (org.mybatis.generator.internal.util.messages.Messages.getString)4 CompilationUnit (org.mybatis.generator.api.dom.java.CompilationUnit)3 CommentGenerator (org.mybatis.generator.api.CommentGenerator)2 FullyQualifiedTable (org.mybatis.generator.api.FullyQualifiedTable)2 Interface (org.mybatis.generator.api.dom.java.Interface)2 DAOMethodNameCalculator (org.mybatis.generator.api.DAOMethodNameCalculator)1 Rules (org.mybatis.generator.internal.rules.Rules)1