Java Code Examples for org.mybatis.generator.api.dom.java.InnerClass#addMethod()
The following examples show how to use
org.mybatis.generator.api.dom.java.InnerClass#addMethod() .
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: DynamicSqlSupportClassGenerator.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
private InnerClass buildInnerTableClass(TopLevelClass topLevelClass) { FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getFullyQualifiedTable().getDomainObjectName()); InnerClass innerClass = new InnerClass(fqjt.getShortName()); innerClass.setVisibility(JavaVisibility.PUBLIC); innerClass.setStatic(true); innerClass.setFinal(true); innerClass.setSuperClass(new FullyQualifiedJavaType("org.mybatis.dynamic.sql.SqlTable")); Method method = new Method(fqjt.getShortName()); method.setVisibility(JavaVisibility.PUBLIC); method.setConstructor(true); method.addBodyLine("super(\"" + escapeStringForJava(introspectedTable.getFullyQualifiedTableNameAtRuntime()) + "\");"); innerClass.addMethod(method); commentGenerator.addClassAnnotation(innerClass, introspectedTable, topLevelClass.getImportedTypes()); return innerClass; }
Example 2
Source File: DynamicSqlSupportClassGenerator.java From mybatis-generator-plugins with Apache License 2.0 | 6 votes |
private InnerClass buildInnerTableClass(TopLevelClass topLevelClass) { FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(sqlTableClassName); InnerClass innerClass = new InnerClass(fqjt.getShortName()); innerClass.setVisibility(JavaVisibility.PUBLIC); innerClass.setStatic(true); innerClass.setFinal(true); innerClass.setSuperClass(new FullyQualifiedJavaType("org.mybatis.dynamic.sql.SqlTable")); //$NON-NLS-1$ Method method = new Method(fqjt.getShortName()); method.setVisibility(JavaVisibility.PUBLIC); method.setConstructor(true); method.addBodyLine("super(\"" //$NON-NLS-1$ + escapeStringForJava(introspectedTable.getFullyQualifiedTableNameAtRuntime()) + "\");"); //$NON-NLS-1$ innerClass.addMethod(method); commentGenerator.addClassAnnotation(innerClass, introspectedTable, topLevelClass.getImportedTypes()); return innerClass; }
Example 3
Source File: CaseInsensitiveLikePlugin.java From mybatis-generator-core-fix with Apache License 2.0 | 4 votes |
@Override public boolean modelExampleClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { InnerClass criteria = null; // first, find the Criteria inner class for (InnerClass innerClass : topLevelClass.getInnerClasses()) { if ("GeneratedCriteria".equals(innerClass.getType().getShortName())) { //$NON-NLS-1$ criteria = innerClass; break; } } if (criteria == null) { // can't find the inner class for some reason, bail out. return true; } for (IntrospectedColumn introspectedColumn : introspectedTable .getNonBLOBColumns()) { if (!introspectedColumn.isJdbcCharacterColumn() || !introspectedColumn.isStringColumn()) { continue; } Method method = new Method(); method.setVisibility(JavaVisibility.PUBLIC); method.addParameter(new Parameter(introspectedColumn .getFullyQualifiedJavaType(), "value")); //$NON-NLS-1$ StringBuilder sb = new StringBuilder(); sb.append(introspectedColumn.getJavaProperty()); sb.setCharAt(0, Character.toUpperCase(sb.charAt(0))); sb.insert(0, "and"); //$NON-NLS-1$ sb.append("LikeInsensitive"); //$NON-NLS-1$ method.setName(sb.toString()); method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance()); sb.setLength(0); sb.append("addCriterion(\"upper("); //$NON-NLS-1$ sb.append(Ibatis2FormattingUtilities .getAliasedActualColumnName(introspectedColumn)); sb.append(") like\", value.toUpperCase(), \""); //$NON-NLS-1$ sb.append(introspectedColumn.getJavaProperty()); sb.append("\");"); //$NON-NLS-1$ method.addBodyLine(sb.toString()); method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$ criteria.addMethod(method); } return true; }
Example 4
Source File: CaseInsensitiveLikePlugin.java From mybatis-generator-plus with Apache License 2.0 | 4 votes |
@Override public boolean modelExampleClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { InnerClass criteria = null; // first, find the Criteria inner class for (InnerClass innerClass : topLevelClass.getInnerClasses()) { if ("GeneratedCriteria".equals(innerClass.getType().getShortName())) { //$NON-NLS-1$ criteria = innerClass; break; } } if (criteria == null) { // can't find the inner class for some reason, bail out. return true; } for (IntrospectedColumn introspectedColumn : introspectedTable .getNonBLOBColumns()) { if (!introspectedColumn.isJdbcCharacterColumn() || !introspectedColumn.isStringColumn()) { continue; } Method method = new Method(); method.setVisibility(JavaVisibility.PUBLIC); method.addParameter(new Parameter(introspectedColumn .getFullyQualifiedJavaType(), "value")); //$NON-NLS-1$ StringBuilder sb = new StringBuilder(); sb.append(introspectedColumn.getJavaProperty()); sb.setCharAt(0, Character.toUpperCase(sb.charAt(0))); sb.insert(0, "and"); //$NON-NLS-1$ sb.append("LikeInsensitive"); //$NON-NLS-1$ method.setName(sb.toString()); method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance()); sb.setLength(0); sb.append("addCriterion(\"upper("); //$NON-NLS-1$ sb.append(Ibatis2FormattingUtilities .getAliasedActualColumnName(introspectedColumn)); sb.append(") like\", value.toUpperCase(), \""); //$NON-NLS-1$ sb.append(introspectedColumn.getJavaProperty()); sb.append("\");"); //$NON-NLS-1$ method.addBodyLine(sb.toString()); method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$ criteria.addMethod(method); } return true; }