Java Code Examples for org.mybatis.generator.api.dom.java.Method#setAbstract()
The following examples show how to use
org.mybatis.generator.api.dom.java.Method#setAbstract() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeleteByExampleMethodGenerator.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
@Override public void addInterfaceElements(Interface interfaze) { Set<FullyQualifiedJavaType> importedTypes = new TreeSet<>(); FullyQualifiedJavaType type = new FullyQualifiedJavaType( introspectedTable.getExampleType()); importedTypes.add(type); Method method = new Method(introspectedTable.getDeleteByExampleStatementId()); method.setVisibility(JavaVisibility.PUBLIC); method.setAbstract(true); method.setReturnType(FullyQualifiedJavaType.getIntInstance()); method.addParameter(new Parameter(type, "example")); context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable); addMapperAnnotations(method); if (context.getPlugins().clientDeleteByExampleMethodGenerated( method, interfaze, introspectedTable)) { addExtraImports(interfaze); interfaze.addImportedTypes(importedTypes); interfaze.addMethod(method); } }
Example 2
Source File: UpdateByPrimaryKeyWithoutBLOBsMethodGenerator.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
@Override public void addInterfaceElements(Interface interfaze) { Set<FullyQualifiedJavaType> importedTypes = new TreeSet<>(); FullyQualifiedJavaType parameterType = new FullyQualifiedJavaType( introspectedTable.getBaseRecordType()); importedTypes.add(parameterType); Method method = new Method(introspectedTable.getUpdateByPrimaryKeyStatementId()); method.setVisibility(JavaVisibility.PUBLIC); method.setAbstract(true); method.setReturnType(FullyQualifiedJavaType.getIntInstance()); method.addParameter(new Parameter(parameterType, "record")); context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable); addMapperAnnotations(method); if (context.getPlugins() .clientUpdateByPrimaryKeyWithoutBLOBsMethodGenerated(method, interfaze, introspectedTable)) { addExtraImports(interfaze); interfaze.addImportedTypes(importedTypes); interfaze.addMethod(method); } }
Example 3
Source File: CountByExampleMethodGenerator.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
@Override public void addInterfaceElements(Interface interfaze) { FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType( introspectedTable.getExampleType()); Set<FullyQualifiedJavaType> importedTypes = new TreeSet<>(); importedTypes.add(fqjt); Method method = new Method(introspectedTable.getCountByExampleStatementId()); method.setVisibility(JavaVisibility.PUBLIC); method.setAbstract(true); method.setReturnType(new FullyQualifiedJavaType("long")); method.addParameter(new Parameter(fqjt, "example")); context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable); addMapperAnnotations(method); if (context.getPlugins().clientCountByExampleMethodGenerated(method, interfaze, introspectedTable)) { addExtraImports(interfaze); interfaze.addImportedTypes(importedTypes); interfaze.addMethod(method); } }
Example 4
Source File: BasicUpdateMethodGenerator.java From mapper-generator-javafx with Apache License 2.0 | 5 votes |
@Override public MethodAndImports generateMethodAndImports() { if (!introspectedTable.getRules().generateUpdateByExampleSelective() && !introspectedTable.getRules().generateUpdateByExampleWithBLOBs() && !introspectedTable.getRules().generateUpdateByExampleWithoutBLOBs() && !introspectedTable.getRules().generateUpdateByPrimaryKeySelective() && !introspectedTable.getRules().generateUpdateByPrimaryKeyWithBLOBs() && !introspectedTable.getRules().generateUpdateByPrimaryKeyWithoutBLOBs()) { return null; } Set<FullyQualifiedJavaType> imports = new HashSet<>(); FullyQualifiedJavaType parameterType = new FullyQualifiedJavaType( "org.mybatis.dynamic.sql.update.render.UpdateStatementProvider"); FullyQualifiedJavaType adapter = new FullyQualifiedJavaType("org.mybatis.dynamic.sql.util.SqlProviderAdapter"); FullyQualifiedJavaType annotation = new FullyQualifiedJavaType("org.apache.ibatis.annotations.UpdateProvider"); imports.add(parameterType); imports.add(adapter); imports.add(annotation); Method method = new Method("update"); method.setAbstract(true); method.setReturnType(FullyQualifiedJavaType.getIntInstance()); method.addParameter(new Parameter(parameterType, "updateStatement")); context.getCommentGenerator().addGeneralMethodAnnotation(method, introspectedTable, imports); method.addAnnotation("@UpdateProvider(type=SqlProviderAdapter.class, method=\"update\")"); return MethodAndImports.withMethod(method) .withImports(imports) .build(); }
Example 5
Source File: BasicCountMethodGenerator.java From mapper-generator-javafx with Apache License 2.0 | 5 votes |
@Override public MethodAndImports generateMethodAndImports() { if (!introspectedTable.getRules().generateCountByExample()) { return null; } Set<FullyQualifiedJavaType> imports = new HashSet<>(); FullyQualifiedJavaType parameterType = new FullyQualifiedJavaType( "org.mybatis.dynamic.sql.select.render.SelectStatementProvider"); FullyQualifiedJavaType adapter = new FullyQualifiedJavaType("org.mybatis.dynamic.sql.util.SqlProviderAdapter"); FullyQualifiedJavaType annotation = new FullyQualifiedJavaType("org.apache.ibatis.annotations.SelectProvider"); imports.add(parameterType); imports.add(adapter); imports.add(annotation); Method method = new Method("count"); method.setAbstract(true); method.setReturnType(new FullyQualifiedJavaType("long")); method.addParameter(new Parameter(parameterType, "selectStatement")); context.getCommentGenerator().addGeneralMethodAnnotation(method, introspectedTable, imports); method.addAnnotation("@SelectProvider(type=SqlProviderAdapter.class, method=\"select\")"); return MethodAndImports.withMethod(method) .withImports(imports) .build(); }
Example 6
Source File: BasicDeleteMethodGenerator.java From mapper-generator-javafx with Apache License 2.0 | 5 votes |
@Override public MethodAndImports generateMethodAndImports() { if (!introspectedTable.getRules().generateDeleteByExample() && !introspectedTable.getRules().generateDeleteByPrimaryKey()) { return null; } Set<FullyQualifiedJavaType> imports = new HashSet<>(); FullyQualifiedJavaType parameterType = new FullyQualifiedJavaType( "org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider"); FullyQualifiedJavaType adapter = new FullyQualifiedJavaType("org.mybatis.dynamic.sql.util.SqlProviderAdapter"); FullyQualifiedJavaType annotation = new FullyQualifiedJavaType("org.apache.ibatis.annotations.DeleteProvider"); imports.add(parameterType); imports.add(adapter); imports.add(annotation); Method method = new Method("delete"); method.setAbstract(true); method.setReturnType(FullyQualifiedJavaType.getIntInstance()); method.addParameter(new Parameter(parameterType, "deleteStatement")); context.getCommentGenerator().addGeneralMethodAnnotation(method, introspectedTable, imports); method.addAnnotation("@DeleteProvider(type=SqlProviderAdapter.class, method=\"delete\")"); return MethodAndImports.withMethod(method) .withImports(imports) .build(); }
Example 7
Source File: InsertSelectiveMethodGenerator.java From mapper-generator-javafx with Apache License 2.0 | 5 votes |
@Override public void addInterfaceElements(Interface interfaze) { Method method = new Method(introspectedTable.getInsertSelectiveStatementId()); method.setReturnType(FullyQualifiedJavaType.getIntInstance()); method.setVisibility(JavaVisibility.PUBLIC); method.setAbstract(true); FullyQualifiedJavaType parameterType = introspectedTable.getRules() .calculateAllFieldsClass(); Set<FullyQualifiedJavaType> importedTypes = new TreeSet<>(); importedTypes.add(parameterType); 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); } }
Example 8
Source File: UpdateByExampleSelectiveMethodGenerator.java From mapper-generator-javafx with Apache License 2.0 | 5 votes |
@Override public void addInterfaceElements(Interface interfaze) { Method method = new Method(introspectedTable .getUpdateByExampleSelectiveStatementId()); method.setVisibility(JavaVisibility.PUBLIC); method.setAbstract(true); method.setReturnType(FullyQualifiedJavaType.getIntInstance()); FullyQualifiedJavaType parameterType = introspectedTable.getRules().calculateAllFieldsClass(); method.addParameter(new Parameter(parameterType, "record", "@Param(\"record\")")); //$NON-NLS-2$ Set<FullyQualifiedJavaType> importedTypes = new TreeSet<>(); importedTypes.add(parameterType); FullyQualifiedJavaType exampleType = new FullyQualifiedJavaType( introspectedTable.getExampleType()); method.addParameter(new Parameter(exampleType, "example", "@Param(\"example\")")); //$NON-NLS-2$ importedTypes.add(exampleType); importedTypes.add(new FullyQualifiedJavaType( "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); } }
Example 9
Source File: BasicInsertMethodGenerator.java From mapper-generator-javafx with Apache License 2.0 | 4 votes |
@Override public MethodAndImports generateMethodAndImports() { if (!introspectedTable.getRules().generateInsert() && !introspectedTable.getRules().generateInsertSelective()) { return null; } Set<FullyQualifiedJavaType> imports = new HashSet<>(); FullyQualifiedJavaType adapter = new FullyQualifiedJavaType("org.mybatis.dynamic.sql.util.SqlProviderAdapter"); FullyQualifiedJavaType annotation = new FullyQualifiedJavaType("org.apache.ibatis.annotations.InsertProvider"); imports.add(new FullyQualifiedJavaType( "org.mybatis.dynamic.sql.insert.render.InsertStatementProvider")); imports.add(adapter); imports.add(annotation); FullyQualifiedJavaType parameterType = new FullyQualifiedJavaType( "org.mybatis.dynamic.sql.insert.render.InsertStatementProvider"); imports.add(recordType); parameterType.addTypeArgument(recordType); Method method = new Method("insert"); method.setAbstract(true); method.setReturnType(FullyQualifiedJavaType.getIntInstance()); method.addParameter(new Parameter(parameterType, "insertStatement")); context.getCommentGenerator().addGeneralMethodAnnotation(method, introspectedTable, imports); method.addAnnotation("@InsertProvider(type=SqlProviderAdapter.class, method=\"insert\")"); MethodAndImports.Builder builder = MethodAndImports.withMethod(method) .withImports(imports); GeneratedKey gk = introspectedTable.getGeneratedKey(); if (gk != null) { MethodParts methodParts = fragmentGenerator.getGeneratedKeyAnnotation(gk); acceptParts(builder, method, methodParts); } return builder.build(); }
Example 10
Source File: BasicSelectManyMethodGenerator.java From mapper-generator-javafx with Apache License 2.0 | 4 votes |
@Override public MethodAndImports generateMethodAndImports() { if (!introspectedTable.getRules().generateSelectByExampleWithBLOBs() && !introspectedTable.getRules().generateSelectByExampleWithoutBLOBs()) { return null; } Set<FullyQualifiedJavaType> imports = new HashSet<>(); FullyQualifiedJavaType parameterType = new FullyQualifiedJavaType( "org.mybatis.dynamic.sql.select.render.SelectStatementProvider"); FullyQualifiedJavaType adapter = new FullyQualifiedJavaType("org.mybatis.dynamic.sql.util.SqlProviderAdapter"); FullyQualifiedJavaType annotation = new FullyQualifiedJavaType("org.apache.ibatis.annotations.SelectProvider"); imports.add(parameterType); imports.add(adapter); imports.add(annotation); imports.add(FullyQualifiedJavaType.getNewListInstance()); imports.add(recordType); FullyQualifiedJavaType returnType = FullyQualifiedJavaType.getNewListInstance(); returnType.addTypeArgument(recordType); Method method = new Method("selectMany"); method.setAbstract(true); method.setReturnType(returnType); method.addParameter(new Parameter(parameterType, "selectStatement")); context.getCommentGenerator().addGeneralMethodAnnotation(method, introspectedTable, imports); method.addAnnotation("@SelectProvider(type=SqlProviderAdapter.class, method=\"select\")"); MethodAndImports.Builder builder = MethodAndImports.withMethod(method) .withImports(imports); MethodParts methodParts; if (introspectedTable.isConstructorBased()) { methodParts = fragmentGenerator.getAnnotatedConstructorArgs(); } else { methodParts = fragmentGenerator.getAnnotatedResults(); } acceptParts(builder, method, methodParts); return builder.build(); }