org.mybatis.generator.api.dom.java.InnerClass Java Examples
The following examples show how to use
org.mybatis.generator.api.dom.java.InnerClass.
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 mybatis-generator-plugins with Apache License 2.0 | 6 votes |
private void handleAliases(TopLevelClass topLevelClass, InnerClass innerClass, String tableFieldName) { // Standard MBG table alias String alias = introspectedTable.getFullyQualifiedTable().getAlias(); if (addTableAlias && StringUtils.isNotBlank(alias) && StringUtils.isNotBlank(tableAliasFieldName)) { handleAlias(topLevelClass, innerClass, tableFieldName, tableAliasFieldName, alias); } // Extra aliases for (Map.Entry<Object, Object> entry : properties.entrySet()) { String key = (String) entry.getKey(); String value = (String) entry.getValue(); if (key.startsWith(introspectedTable.getFullyQualifiedTableNameAtRuntime() + ".")) { String aliasField = key.substring(introspectedTable.getFullyQualifiedTableNameAtRuntime().length() + 1); handleAlias(topLevelClass, innerClass, tableFieldName, aliasField, value); } } }
Example #2
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 #3
Source File: DynamicSqlSupportClassGenerator.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
public TopLevelClass generate() { TopLevelClass topLevelClass = buildBasicClass(); Field tableField = calculateTableDefinition(topLevelClass); topLevelClass.addImportedType(tableField.getType()); topLevelClass.addField(tableField); InnerClass innerClass = buildInnerTableClass(topLevelClass); topLevelClass.addInnerClass(innerClass); List<IntrospectedColumn> columns = introspectedTable.getAllColumns(); for (IntrospectedColumn column : columns) { handleColumn(topLevelClass, innerClass, column, tableField.getName()); } return topLevelClass; }
Example #4
Source File: DefaultCommentGenerator.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
@Override public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean markAsDoNotDelete) { if (suppressAllComments) { return; } StringBuilder sb = new StringBuilder(); innerClass.addJavaDocLine("/**"); innerClass .addJavaDocLine(" * This class was generated by MyBatis Generator."); sb.append(" * This class corresponds to the database table "); sb.append(introspectedTable.getFullyQualifiedTable()); innerClass.addJavaDocLine(sb.toString()); addJavadocTag(innerClass, markAsDoNotDelete); innerClass.addJavaDocLine(" */"); }
Example #5
Source File: DefaultCommentGenerator.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
@Override public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable) { if (suppressAllComments) { return; } StringBuilder sb = new StringBuilder(); innerClass.addJavaDocLine("/**"); innerClass.addJavaDocLine(" * This class was generated by MyBatis Generator."); sb.append(" * This class corresponds to the database table "); sb.append(introspectedTable.getFullyQualifiedTable()); innerClass.addJavaDocLine(sb.toString()); addJavadocTag(innerClass, false); innerClass.addJavaDocLine(" */"); }
Example #6
Source File: DefaultCommentGenerator.java From mybatis-generator-plus with Apache License 2.0 | 6 votes |
public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable) { if (suppressAllComments) { return; } StringBuilder sb = new StringBuilder(); innerClass.addJavaDocLine("/**"); //$NON-NLS-1$ innerClass .addJavaDocLine(" * This class was generated by MyBatis Generator."); //$NON-NLS-1$ sb.append(" * This class corresponds to the database table "); //$NON-NLS-1$ sb.append(introspectedTable.getFullyQualifiedTable()); innerClass.addJavaDocLine(sb.toString()); addJavadocTag(innerClass, false); innerClass.addJavaDocLine(" */"); //$NON-NLS-1$ }
Example #7
Source File: DefaultCommentGenerator.java From mybatis-generator-plus with Apache License 2.0 | 6 votes |
public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean markAsDoNotDelete) { if (suppressAllComments) { return; } StringBuilder sb = new StringBuilder(); innerClass.addJavaDocLine("/**"); //$NON-NLS-1$ innerClass .addJavaDocLine(" * This class was generated by MyBatis Generator."); //$NON-NLS-1$ sb.append(" * This class corresponds to the database table "); //$NON-NLS-1$ sb.append(introspectedTable.getFullyQualifiedTable()); innerClass.addJavaDocLine(sb.toString()); addJavadocTag(innerClass, markAsDoNotDelete); innerClass.addJavaDocLine(" */"); //$NON-NLS-1$ }
Example #8
Source File: CustomSerializablePlugin.java From mybatis-generator-plus with Apache License 2.0 | 6 votes |
/** * 添加给Example类序列化的方法 * * @param topLevelClass * @param introspectedTable * @return */ @Override public boolean modelExampleClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { makeSerializable(topLevelClass, introspectedTable); for (InnerClass innerClass : topLevelClass.getInnerClasses()) { if ("GeneratedCriteria".equals(innerClass.getType().getShortName())) { //$NON-NLS-1$ innerClass.addSuperInterface(serializable); } if ("Criteria".equals(innerClass.getType().getShortName())) { //$NON-NLS-1$ innerClass.addSuperInterface(serializable); } if ("Criterion".equals(innerClass.getType().getShortName())) { //$NON-NLS-1$ innerClass.addSuperInterface(serializable); } } return true; }
Example #9
Source File: DynamicSqlSupportClassGenerator.java From mybatis-generator-plugins with Apache License 2.0 | 6 votes |
public TopLevelClass generate() { TopLevelClass topLevelClass = buildBasicClass(); Field tableField = calculateTableDefinition(topLevelClass); topLevelClass.addImportedType(tableField.getType()); topLevelClass.addField(tableField); InnerClass innerClass = buildInnerTableClass(topLevelClass); topLevelClass.addInnerClass(innerClass); handleAliases(topLevelClass, innerClass, tableField.getName()); List<IntrospectedColumn> columns = introspectedTable.getAllColumns(); for (IntrospectedColumn column : columns) { handleColumn(topLevelClass, innerClass, column, tableField.getName()); } return topLevelClass; }
Example #10
Source File: InnerClassRenderer.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
private String renderFirstLine(InnerClass innerClass, CompilationUnit compilationUnit) { StringBuilder sb = new StringBuilder(); sb.append(innerClass.getVisibility().getValue()); if (innerClass.isAbstract()) { sb.append("abstract "); } if (innerClass.isStatic()) { sb.append("static "); } if (innerClass.isFinal()) { sb.append("final "); } sb.append("class "); sb.append(innerClass.getType().getShortName()); sb.append(RenderingUtilities.renderTypeParameters(innerClass.getTypeParameters(), compilationUnit)); sb.append(renderSuperClass(innerClass, compilationUnit)); sb.append(renderSuperInterfaces(innerClass, compilationUnit)); sb.append(" {"); return sb.toString(); }
Example #11
Source File: InnerClassRenderer.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
public List<String> render(InnerClass innerClass, CompilationUnit compilationUnit) { List<String> lines = new ArrayList<>(); lines.addAll(innerClass.getJavaDocLines()); lines.addAll(innerClass.getAnnotations()); lines.add(renderFirstLine(innerClass, compilationUnit)); lines.addAll(RenderingUtilities.renderFields(innerClass.getFields(), compilationUnit)); lines.addAll(RenderingUtilities.renderInitializationBlocks(innerClass.getInitializationBlocks())); lines.addAll(RenderingUtilities.renderClassOrEnumMethods(innerClass.getMethods(), compilationUnit)); lines.addAll(RenderingUtilities.renderInnerClasses(innerClass.getInnerClasses(), compilationUnit)); lines.addAll(RenderingUtilities.renderInnerInterfaces(innerClass.getInnerInterfaces(), compilationUnit)); lines.addAll(RenderingUtilities.renderInnerEnums(innerClass.getInnerEnums(), compilationUnit)); lines = RenderingUtilities.removeLastEmptyLine(lines); lines.add("}"); return lines; }
Example #12
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 #13
Source File: DG2CommentGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
@Override public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean markAsDoNotDelete) { // 类注释,不管用 String shortName = innerClass.getType().getShortName(); innerClass.addJavaDocLine("/**"); innerClass.addJavaDocLine(" * 类注释"); innerClass.addJavaDocLine(" * " + shortName); innerClass.addJavaDocLine(" * 数据库表:" + introspectedTable.getFullyQualifiedTable()); // addJavadocTag(innerClass, false); innerClass.addJavaDocLine(" */"); }
Example #14
Source File: DG2CommentGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
@Override public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable) { // 类注释,不管用 String shortName = innerClass.getType().getShortName(); innerClass.addJavaDocLine("/**"); //innerClass.addJavaDocLine(" * 类注释"); //获取数据库表的备注信息 innerClass.addJavaDocLine(" * " + introspectedTable.getFullyQualifiedTable().getRemark()); //model对象的名称 innerClass.addJavaDocLine(" * " + shortName); //获取数据库表 innerClass.addJavaDocLine(" * 数据库表:" + introspectedTable.getFullyQualifiedTable()); // addJavadocTag(innerClass, false); innerClass.addJavaDocLine(" */"); }
Example #15
Source File: DGCommentGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
@Override public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean markAsDoNotDelete) { // 类注释,不管用 String shortName = innerClass.getType().getShortName(); innerClass.addJavaDocLine("/**"); innerClass.addJavaDocLine(" * 类注释"); innerClass.addJavaDocLine(" * " + shortName); innerClass.addJavaDocLine(" * 数据库表:" + introspectedTable.getFullyQualifiedTable()); // addJavadocTag(innerClass, false); innerClass.addJavaDocLine(" */"); }
Example #16
Source File: DGCommentGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
@Override public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable) { // 类注释,不管用 String shortName = innerClass.getType().getShortName(); innerClass.addJavaDocLine("/**"); innerClass.addJavaDocLine(" * 类注释"); innerClass.addJavaDocLine(" * " + shortName); innerClass.addJavaDocLine(" * 数据库表:" + introspectedTable.getFullyQualifiedTable()); // addJavadocTag(innerClass, false); innerClass.addJavaDocLine(" */"); }
Example #17
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; }
Example #18
Source File: MyMapperCommentGenerator.java From jvue-admin with MIT License | 4 votes |
@Override public void addClassAnnotation(InnerClass innerClass, IntrospectedTable introspectedTable, Set<FullyQualifiedJavaType> imports) { // TODO Auto-generated method stub }
Example #19
Source File: CommentGenerator.java From mybatis-generator-plus with Apache License 2.0 | 4 votes |
public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean markAsDoNotDelete);
Example #20
Source File: CommentGenerator.java From mybatis-generator-plus with Apache License 2.0 | 4 votes |
public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable);
Example #21
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 #22
Source File: CaseInsensitiveLikePlugin.java From mapper-generator-javafx with Apache License 2.0 | 4 votes |
private void addMethods(IntrospectedTable introspectedTable, InnerClass criteria) { introspectedTable.getNonBLOBColumns().stream() .filter(this::isEligibleColumn) .map(this::toMethod) .forEach(criteria::addMethod); }
Example #23
Source File: CaseInsensitiveLikePlugin.java From mapper-generator-javafx with Apache License 2.0 | 4 votes |
private boolean isGeneratedCriteria(InnerClass innerClass) { return "GeneratedCriteria".equals(innerClass.getType().getShortName()); }
Example #24
Source File: RenderingUtilities.java From mapper-generator-javafx with Apache License 2.0 | 4 votes |
private static Stream<String> renderInnerClass(InnerClass innerClass, CompilationUnit compilationUnit) { return addEmptyLine(innerClassRenderer.render(innerClass, compilationUnit).stream() .map(RenderingUtilities::javaIndent)); }
Example #25
Source File: RenderingUtilities.java From mapper-generator-javafx with Apache License 2.0 | 4 votes |
public static List<String> renderInnerClassNoIndent(InnerClass innerClass, CompilationUnit compilationUnit) { return innerClassRenderer.render(innerClass, compilationUnit); }
Example #26
Source File: RenderingUtilities.java From mapper-generator-javafx with Apache License 2.0 | 4 votes |
public static List<String> renderInnerClasses(List<InnerClass> innerClasses, CompilationUnit compilationUnit) { return innerClasses.stream() .flatMap(ic -> renderInnerClass(ic, compilationUnit)) .collect(Collectors.toList()); }
Example #27
Source File: InnerClassRenderer.java From mapper-generator-javafx with Apache License 2.0 | 4 votes |
private String renderSuperInterfaces(InnerClass innerClass, CompilationUnit compilationUnit) { return innerClass.getSuperInterfaceTypes().stream() .map(tp -> JavaDomUtils.calculateTypeName(compilationUnit, tp)) .collect(CustomCollectors.joining(", ", " implements ", "")); //$NON-NLS-2$ //$NON-NLS-3$ }
Example #28
Source File: InnerClassRenderer.java From mapper-generator-javafx with Apache License 2.0 | 4 votes |
private String renderSuperClass(InnerClass innerClass, CompilationUnit compilationUnit) { return innerClass.getSuperClass() .map(sc -> " extends " + JavaDomUtils.calculateTypeName(compilationUnit, sc)) .orElse(""); }
Example #29
Source File: CommentGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 2 votes |
/** * Adds the inner class comment. * * @param innerClass * the inner class * @param introspectedTable * the introspected table */ public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable);
Example #30
Source File: CommentGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 2 votes |
/** * Adds the inner class comment. * * @param innerClass * the inner class * @param introspectedTable * the introspected table * @param markAsDoNotDelete * the mark as do not delete */ public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean markAsDoNotDelete);