org.mybatis.generator.api.dom.java.Interface Java Examples
The following examples show how to use
org.mybatis.generator.api.dom.java.Interface.
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 mybatis-generator-plus with Apache License 2.0 | 6 votes |
@Override public void addInterfaceElements(Interface interfaze) { Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>(); FullyQualifiedJavaType type = new FullyQualifiedJavaType( introspectedTable.getExampleType()); importedTypes.add(type); Method method = new Method(); method.setVisibility(JavaVisibility.PUBLIC); method.setReturnType(FullyQualifiedJavaType.getIntInstance()); method.setName(introspectedTable.getDeleteByExampleStatementId()); method.addParameter(new Parameter(type, "example")); //$NON-NLS-1$ context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable); addMapperAnnotations(interfaze, method); if (context.getPlugins().clientDeleteByExampleMethodGenerated( method, interfaze, introspectedTable)) { interfaze.addImportedTypes(importedTypes); interfaze.addMethod(method); } }
Example #2
Source File: DeleteByExampleMethodGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 6 votes |
@Override public void addInterfaceElements(Interface interfaze) { Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>(); FullyQualifiedJavaType type = new FullyQualifiedJavaType( introspectedTable.getExampleType()); importedTypes.add(type); Method method = new Method(); method.setVisibility(JavaVisibility.PUBLIC); method.setReturnType(FullyQualifiedJavaType.getIntInstance()); method.setName(introspectedTable.getDeleteByExampleStatementId()); method.addParameter(new Parameter(type, "example")); //$NON-NLS-1$ context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable); addMapperAnnotations(interfaze, method); if (context.getPlugins().clientDeleteByExampleMethodGenerated( method, interfaze, introspectedTable)) { interfaze.addImportedTypes(importedTypes); interfaze.addMethod(method); } }
Example #3
Source File: CreateGenericInterfacePlugin.java From mybatis-generator-plugins with Apache License 2.0 | 6 votes |
private void init() { genericModelList = FullyQualifiedJavaType.getNewListInstance(); genericModelList.addTypeArgument(genericModel); longPrimitive = new FullyQualifiedJavaType("long"); FullyQualifiedJavaType className = new FullyQualifiedJavaType(interfaceName); className.addTypeArgument(genericModel); className.addTypeArgument(genericExample); className.addTypeArgument(genericId); genericInterface = new Interface(className); genericInterface.setVisibility(JavaVisibility.PUBLIC); methodsAdded = new HashSet<>(); models = new HashMap<>(); examples = new HashMap<>(); ids = new HashMap<>(); }
Example #4
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 #5
Source File: SelectiveEnhancedPlugin.java From mybatis-generator-plugin with Apache License 2.0 | 6 votes |
/** * updateByExampleSelective * 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html * @param method * @param interfaze * @param introspectedTable * @return */ @Override public boolean clientUpdateByExampleSelectiveMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) { method.getParameters().clear(); FullyQualifiedJavaType parameterType = introspectedTable.getRules().calculateAllFieldsClass(); method.addParameter(new Parameter(parameterType, "record", "@Param(\"record\")")); FullyQualifiedJavaType exampleType = new FullyQualifiedJavaType(introspectedTable.getExampleType()); method.addParameter(new Parameter(exampleType, "example", "@Param(\"example\")")); // 找出全字段对应的Model FullyQualifiedJavaType fullFieldModel = introspectedTable.getRules().calculateAllFieldsClass(); // column枚举 FullyQualifiedJavaType selectiveType = new FullyQualifiedJavaType(fullFieldModel.getShortName() + "." + ModelColumnPlugin.ENUM_NAME); method.addParameter(new Parameter(selectiveType, "selective", "@Param(\"selective\")", true)); FormatTools.replaceGeneralMethodComment(commentGenerator, method, introspectedTable); return super.clientUpdateByExampleSelectiveMethodGenerated(method, interfaze, introspectedTable); }
Example #6
Source File: UpdateByPrimaryKeyWithoutBLOBsMethodGenerator.java From mybatis-generator-plus with Apache License 2.0 | 6 votes |
@Override public void addInterfaceElements(Interface interfaze) { Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>(); FullyQualifiedJavaType parameterType = new FullyQualifiedJavaType( introspectedTable.getBaseRecordType()); importedTypes.add(parameterType); Method method = new Method(); method.setVisibility(JavaVisibility.PUBLIC); method.setReturnType(FullyQualifiedJavaType.getIntInstance()); method.setName(introspectedTable.getUpdateByPrimaryKeyStatementId()); method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$ context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable); addMapperAnnotations(interfaze, method); if (context.getPlugins() .clientUpdateByPrimaryKeyWithoutBLOBsMethodGenerated(method, interfaze, introspectedTable)) { interfaze.addImportedTypes(importedTypes); interfaze.addMethod(method); } }
Example #7
Source File: MapperExtendsPlugin.java From S-mall-ssm with GNU General Public License v3.0 | 6 votes |
@Override public boolean clientGenerated(Interface interfaze, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { // 获取实体类 FullyQualifiedJavaType entityType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType()); // 获取Example类 FullyQualifiedJavaType exampleType = new FullyQualifiedJavaType(introspectedTable.getExampleType()); // import接口 for (String mapper : mappers) { interfaze.addImportedType(new FullyQualifiedJavaType(mapper)); interfaze.addSuperInterface( new FullyQualifiedJavaType( mapper + "<" + entityType.getShortName() + "," + exampleType.getShortName() + ">")); } // import实体类 interfaze.addImportedType(entityType); return true; }
Example #8
Source File: DAOGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
protected void addUpdateByExampleSelectiveMethod( TopLevelClass topLevelClass, Interface interfaze) { if (introspectedTable.getRules().generateUpdateByExampleSelective()) { AbstractDAOElementGenerator methodGenerator = new UpdateByExampleSelectiveMethodGenerator(); initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze); } }
Example #9
Source File: AnnotatedUpdateByExampleSelectiveMethodGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
@Override public void addMapperAnnotations(Interface interfaze, Method method) { FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType()); interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.UpdateProvider")); //$NON-NLS-1$ StringBuilder sb = new StringBuilder(); sb.append("@UpdateProvider(type="); //$NON-NLS-1$ sb.append(fqjt.getShortName()); sb.append(".class, method=\""); //$NON-NLS-1$ sb.append(introspectedTable.getUpdateByExampleSelectiveStatementId()); sb.append("\")"); //$NON-NLS-1$ method.addAnnotation(sb.toString()); }
Example #10
Source File: SimpleJavaClientGenerator.java From mybatis-generator-plus with Apache License 2.0 | 5 votes |
protected void initializeAndExecuteGenerator( AbstractJavaMapperMethodGenerator methodGenerator, Interface interfaze) { methodGenerator.setContext(context); methodGenerator.setIntrospectedTable(introspectedTable); methodGenerator.setProgressCallback(progressCallback); methodGenerator.setWarnings(warnings); methodGenerator.addInterfaceElements(interfaze); }
Example #11
Source File: SimpleAnnotatedClientGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
@Override protected void addSelectByPrimaryKeyMethod(Interface interfaze) { if (introspectedTable.getRules().generateSelectByPrimaryKey()) { AbstractJavaMapperMethodGenerator methodGenerator = new AnnotatedSelectByPrimaryKeyMethodGenerator(false, true); initializeAndExecuteGenerator(methodGenerator, interfaze); } }
Example #12
Source File: AnnotatedClientGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
@Override protected void addUpdateByPrimaryKeySelectiveMethod(Interface interfaze) { if (introspectedTable.getRules().generateUpdateByPrimaryKeySelective()) { AbstractJavaMapperMethodGenerator methodGenerator = new AnnotatedUpdateByPrimaryKeySelectiveMethodGenerator(); initializeAndExecuteGenerator(methodGenerator, interfaze); } }
Example #13
Source File: AnnotatedSelectByPrimaryKeyMethodGenerator.java From mapper-generator-javafx with Apache License 2.0 | 5 votes |
private void addAnnotationImports(Interface interfaze) { interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.type.JdbcType")); if (introspectedTable.isConstructorBased()) { interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Arg")); interfaze.addImportedType( new FullyQualifiedJavaType("org.apache.ibatis.annotations.ConstructorArgs")); } else { interfaze.addImportedType( new FullyQualifiedJavaType("org.apache.ibatis.annotations.Result")); interfaze.addImportedType( new FullyQualifiedJavaType("org.apache.ibatis.annotations.Results")); } }
Example #14
Source File: AnnotatedClientGenerator.java From mapper-generator-javafx with Apache License 2.0 | 5 votes |
@Override protected void addDeleteByPrimaryKeyMethod(Interface interfaze) { if (introspectedTable.getRules().generateDeleteByPrimaryKey()) { AbstractJavaMapperMethodGenerator methodGenerator = new AnnotatedDeleteByPrimaryKeyMethodGenerator(false); initializeAndExecuteGenerator(methodGenerator, interfaze); } }
Example #15
Source File: DAOGenerator.java From mybatis-generator-plus with Apache License 2.0 | 5 votes |
protected void addUpdateByExampleWithBLOBsMethod( TopLevelClass topLevelClass, Interface interfaze) { if (introspectedTable.getRules().generateUpdateByExampleWithBLOBs()) { AbstractDAOElementGenerator methodGenerator = new UpdateByExampleWithBLOBsMethodGenerator(); initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze); } }
Example #16
Source File: SelectByPrimaryKeyMethodGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
@Override public void addInterfaceElements(Interface interfaze) { Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>(); Method method = getMethodShell(importedTypes); if (context.getPlugins().clientSelectByPrimaryKeyMethodGenerated( method, interfaze, introspectedTable)) { interfaze.addImportedTypes(importedTypes); interfaze.addMethod(method); } }
Example #17
Source File: AnnotatedClientGenerator.java From mybatis-generator-plus with Apache License 2.0 | 5 votes |
@Override protected void addUpdateByExampleWithBLOBsMethod(Interface interfaze) { if (introspectedTable.getRules().generateUpdateByExampleWithBLOBs()) { AbstractJavaMapperMethodGenerator methodGenerator = new AnnotatedUpdateByExampleWithBLOBsMethodGenerator(); initializeAndExecuteGenerator(methodGenerator, interfaze); } }
Example #18
Source File: AnnotatedClientGenerator.java From mybatis-generator-plus with Apache License 2.0 | 5 votes |
@Override protected void addCountByExampleMethod(Interface interfaze) { if (introspectedTable.getRules().generateCountByExample()) { AbstractJavaMapperMethodGenerator methodGenerator = new AnnotatedCountByExampleMethodGenerator(); initializeAndExecuteGenerator(methodGenerator, interfaze); } }
Example #19
Source File: MyPgMapperPlugin.java From jvue-admin with MIT License | 5 votes |
/** * 生成的Mapper接口 * * @param interfaze * @param topLevelClass * @param introspectedTable * @return */ @Override public boolean clientGenerated(Interface interfaze, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { //获取实体类 FullyQualifiedJavaType entityType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType()); //import接口 for (String mapper : mappers) { interfaze.addImportedType(new FullyQualifiedJavaType(mapper)); interfaze.addSuperInterface(new FullyQualifiedJavaType(mapper + "<" + entityType.getShortName() + ">")); } //import实体类 interfaze.addImportedType(entityType); return true; }
Example #20
Source File: SimpleAnnotatedClientGenerator.java From mapper-generator-javafx with Apache License 2.0 | 5 votes |
@Override protected void addSelectByPrimaryKeyMethod(Interface interfaze) { if (introspectedTable.getRules().generateSelectByPrimaryKey()) { AbstractJavaMapperMethodGenerator methodGenerator = new AnnotatedSelectByPrimaryKeyMethodGenerator(false, true); initializeAndExecuteGenerator(methodGenerator, interfaze); } }
Example #21
Source File: InsertMethodGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
@Override public void addInterfaceElements(Interface interfaze) { Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>(); Method method = getMethodShell(importedTypes); if (context.getPlugins().clientInsertMethodGenerated(method, interfaze, introspectedTable)) { interfaze.addImportedTypes(importedTypes); interfaze.addMethod(method); } }
Example #22
Source File: UpdateByExampleSelectiveMethodGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
@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", "@Param(\"record\")")); //$NON-NLS-1$ //$NON-NLS-2$ importedTypes.add(parameterType); FullyQualifiedJavaType exampleType = new FullyQualifiedJavaType( introspectedTable.getExampleType()); method.addParameter(new Parameter(exampleType, "example", "@Param(\"example\")")); //$NON-NLS-1$ //$NON-NLS-2$ importedTypes.add(exampleType); importedTypes.add(new FullyQualifiedJavaType( "org.apache.ibatis.annotations.Param")); //$NON-NLS-1$ context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable); addMapperAnnotations(interfaze, method); if (context.getPlugins() .clientUpdateByExampleSelectiveMethodGenerated(method, interfaze, introspectedTable)) { interfaze.addImportedTypes(importedTypes); interfaze.addMethod(method); } }
Example #23
Source File: SimpleAnnotatedClientGenerator.java From mybatis-generator-plus with Apache License 2.0 | 5 votes |
@Override protected void addInsertMethod(Interface interfaze) { if (introspectedTable.getRules().generateInsert()) { AbstractJavaMapperMethodGenerator methodGenerator = new AnnotatedInsertMethodGenerator(true); initializeAndExecuteGenerator(methodGenerator, interfaze); } }
Example #24
Source File: PluginAggregator.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
public boolean clientSelectByExampleWithBLOBsMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) { boolean rc = true; for (Plugin plugin : plugins) { if (!plugin.clientSelectByExampleWithBLOBsMethodGenerated(method, interfaze, introspectedTable)) { rc = false; break; } } return rc; }
Example #25
Source File: DAOGenerator.java From mybatis-generator-plus with Apache License 2.0 | 5 votes |
@Override public List<CompilationUnit> getCompilationUnits() { FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable(); progressCallback.startTask(getString( "Progress.14", table.toString())); //$NON-NLS-1$ 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; }
Example #26
Source File: AbstractJavaMapperMethodGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
protected void addGeneratedKeyAnnotation(Interface interfaze, Method method, GeneratedKey gk) { StringBuilder sb = new StringBuilder(); IntrospectedColumn introspectedColumn = introspectedTable.getColumn(gk.getColumn()); if (introspectedColumn != null) { if (gk.isJdbcStandard()) { interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Options")); //$NON-NLS-1$ sb.append("@Options(useGeneratedKeys=true,keyProperty=\""); //$NON-NLS-1$ sb.append(introspectedColumn.getJavaProperty()); sb.append("\")"); //$NON-NLS-1$ method.addAnnotation(sb.toString()); } else { interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.SelectKey")); //$NON-NLS-1$ FullyQualifiedJavaType fqjt = introspectedColumn.getFullyQualifiedJavaType(); interfaze.addImportedType(fqjt); sb.append("@SelectKey(statement=\""); //$NON-NLS-1$ sb.append(gk.getRuntimeSqlStatement()); sb.append("\", keyProperty=\""); //$NON-NLS-1$ sb.append(introspectedColumn.getJavaProperty()); sb.append("\", before="); //$NON-NLS-1$ sb.append(gk.isIdentity() ? "false" : "true"); //$NON-NLS-1$ //$NON-NLS-2$ sb.append(", resultType="); //$NON-NLS-1$ sb.append(fqjt.getShortName()); sb.append(".class)"); //$NON-NLS-1$ method.addAnnotation(sb.toString()); } } }
Example #27
Source File: PluginAggregator.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
public boolean clientUpdateByPrimaryKeySelectiveMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) { boolean rc = true; for (Plugin plugin : plugins) { if (!plugin.clientUpdateByPrimaryKeySelectiveMethodGenerated(method, interfaze, introspectedTable)) { rc = false; break; } } return rc; }
Example #28
Source File: AlterResultMapPlugin.java From mybatis-generator-plugins with Apache License 2.0 | 5 votes |
@Override public boolean clientSelectByPrimaryKeyMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) { renameResultMapAttribute(method, introspectedTable); return true; }
Example #29
Source File: PluginAggregator.java From mapper-generator-javafx with Apache License 2.0 | 5 votes |
@Override public boolean clientBasicInsertMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) { boolean rc = true; for (Plugin plugin : plugins) { if (!plugin.clientBasicInsertMethodGenerated(method, interfaze, introspectedTable)) { rc = false; break; } } return rc; }
Example #30
Source File: PluginAggregator.java From mapper-generator-javafx with Apache License 2.0 | 5 votes |
@Override public boolean clientBasicDeleteMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) { boolean rc = true; for (Plugin plugin : plugins) { if (!plugin.clientBasicDeleteMethodGenerated(method, interfaze, introspectedTable)) { rc = false; break; } } return rc; }