org.mybatis.generator.api.dom.java.InnerEnum Java Examples
The following examples show how to use
org.mybatis.generator.api.dom.java.InnerEnum.
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: InnerEnumRenderer.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
public List<String> render(InnerEnum innerEnum, CompilationUnit compilationUnit) { List<String> lines = new ArrayList<>(); lines.addAll(innerEnum.getJavaDocLines()); lines.addAll(innerEnum.getAnnotations()); lines.add(renderFirstLine(innerEnum, compilationUnit)); lines.addAll(renderEnumConstants(innerEnum)); lines.addAll(RenderingUtilities.renderFields(innerEnum.getFields(), compilationUnit)); lines.addAll(RenderingUtilities.renderInitializationBlocks(innerEnum.getInitializationBlocks())); lines.addAll(RenderingUtilities.renderClassOrEnumMethods(innerEnum.getMethods(), compilationUnit)); lines.addAll(RenderingUtilities.renderInnerClasses(innerEnum.getInnerClasses(), compilationUnit)); lines.addAll(RenderingUtilities.renderInnerInterfaces(innerEnum.getInnerInterfaces(), compilationUnit)); lines.addAll(RenderingUtilities.renderInnerEnums(innerEnum.getInnerEnums(), compilationUnit)); lines = RenderingUtilities.removeLastEmptyLine(lines); lines.add("}"); return lines; }
Example #2
Source File: InnerEnumRenderer.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
private String renderFirstLine(InnerEnum innerEnum, CompilationUnit compilationUnit) { StringBuilder sb = new StringBuilder(); sb.append(innerEnum.getVisibility().getValue()); if (innerEnum.isStatic()) { sb.append("static "); } sb.append("enum "); sb.append(innerEnum.getType().getShortName()); sb.append(renderSuperInterfaces(innerEnum, compilationUnit)); sb.append(" {"); return sb.toString(); }
Example #3
Source File: InnerEnumRenderer.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
private List<String> renderEnumConstants(InnerEnum innerEnum) { List<String> answer = new ArrayList<>(); Iterator<String> iter = innerEnum.getEnumConstants().iterator(); while (iter.hasNext()) { String enumConstant = iter.next(); if (iter.hasNext()) { answer.add(RenderingUtilities.JAVA_INDENT + enumConstant + ","); } else { answer.add(RenderingUtilities.JAVA_INDENT + enumConstant + ";"); } } answer.add(""); return answer; }
Example #4
Source File: DefaultCommentGenerator.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
@Override public void addEnumComment(InnerEnum innerEnum, IntrospectedTable introspectedTable) { if (suppressAllComments) { return; } StringBuilder sb = new StringBuilder(); innerEnum.addJavaDocLine("/**"); innerEnum .addJavaDocLine(" * This enum was generated by MyBatis Generator."); sb.append(" * This enum corresponds to the database table "); sb.append(introspectedTable.getFullyQualifiedTable()); innerEnum.addJavaDocLine(sb.toString()); addJavadocTag(innerEnum, false); innerEnum.addJavaDocLine(" */"); }
Example #5
Source File: DefaultCommentGenerator.java From mybatis-generator-plus with Apache License 2.0 | 6 votes |
public void addEnumComment(InnerEnum innerEnum, IntrospectedTable introspectedTable) { if (suppressAllComments) { return; } StringBuilder sb = new StringBuilder(); innerEnum.addJavaDocLine("/**"); //$NON-NLS-1$ innerEnum .addJavaDocLine(" * This enum was generated by MyBatis Generator."); //$NON-NLS-1$ sb.append(" * This enum corresponds to the database table "); //$NON-NLS-1$ sb.append(introspectedTable.getFullyQualifiedTable()); innerEnum.addJavaDocLine(sb.toString()); addJavadocTag(innerEnum, false); innerEnum.addJavaDocLine(" */"); //$NON-NLS-1$ }
Example #6
Source File: InnerEnumRenderer.java From mapper-generator-javafx with Apache License 2.0 | 4 votes |
private String renderSuperInterfaces(InnerEnum innerEnum, CompilationUnit compilationUnit) { return innerEnum.getSuperInterfaceTypes().stream() .map(tp -> JavaDomUtils.calculateTypeName(compilationUnit, tp)) .collect(CustomCollectors.joining(", ", " implements ", "")); //$NON-NLS-2$ //$NON-NLS-3$ }
Example #7
Source File: RenderingUtilities.java From mapper-generator-javafx with Apache License 2.0 | 4 votes |
public static List<String> renderInnerEnums(List<InnerEnum> innerEnums, CompilationUnit compilationUnit) { return innerEnums.stream() .flatMap(ie -> renderInnerEnum(ie, compilationUnit)) .collect(Collectors.toList()); }
Example #8
Source File: RenderingUtilities.java From mapper-generator-javafx with Apache License 2.0 | 4 votes |
public static List<String> renderInnerEnumNoIndent(InnerEnum innerEnum, CompilationUnit compilationUnit) { return innerEnumRenderer.render(innerEnum, compilationUnit); }
Example #9
Source File: RenderingUtilities.java From mapper-generator-javafx with Apache License 2.0 | 4 votes |
private static Stream<String> renderInnerEnum(InnerEnum innerEnum, CompilationUnit compilationUnit) { return addEmptyLine(innerEnumRenderer.render(innerEnum, compilationUnit).stream() .map(RenderingUtilities::javaIndent)); }
Example #10
Source File: HySwaggerMapperPlugin.java From jvue-admin with MIT License | 4 votes |
private void addFieldEnum(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { if (this.modelFieldEnum) { String enumName = "FieldEnum"; String javaFieldName = "javaFieldName"; String dbFieldName = "dbFieldName"; InnerEnum enum1 = new InnerEnum(new FullyQualifiedJavaType(enumName)); enum1.setVisibility(JavaVisibility.PUBLIC); StringBuilder enumConstant = new StringBuilder(); List<IntrospectedColumn> allColumns = introspectedTable.getAllColumns(); int index = 0; for (IntrospectedColumn column : allColumns) { String dbName = column.getActualColumnName(); String javaName = column.getJavaProperty(); enumConstant.append(dbName.toUpperCase()).append("(\"").append(javaName).append("\",\"").append(dbName).append("\")"); if (++index < allColumns.size()) { enumConstant.append(",\n\t\t"); } } enum1.addEnumConstant(enumConstant.toString()); //java字段 Field field = new Field(); field.setVisibility(JavaVisibility.PRIVATE); field.setStatic(false); field.setType(new FullyQualifiedJavaType("String")); field.setName(javaFieldName); enum1.addField(field); //db字段 Field field1 = new Field(); field1.setVisibility(JavaVisibility.PRIVATE); field1.setStatic(false); field1.setType(new FullyQualifiedJavaType("String")); field1.setName(dbFieldName); enum1.addField(field1); //构造器 Method method = new Method(); method.setConstructor(true); method.setVisibility(JavaVisibility.DEFAULT); method.setStatic(false); method.setName(enumName); method.addParameter(new Parameter(new FullyQualifiedJavaType("String"), javaFieldName)); method.addParameter(new Parameter(new FullyQualifiedJavaType("String"), dbFieldName)); method.addBodyLine("this."+javaFieldName+" = "+javaFieldName+";"); method.addBodyLine("this."+dbFieldName+" = "+dbFieldName+";"); enum1.addMethod(method); //方法 Method getMethod = new Method(); getMethod.setConstructor(false); getMethod.setVisibility(JavaVisibility.PUBLIC); getMethod.setStatic(false); getMethod.setName(javaFieldName); getMethod.addBodyLine("return "+javaFieldName+";"); getMethod.setReturnType(new FullyQualifiedJavaType("String")); enum1.addMethod(getMethod); Method getMethod1 = new Method(); getMethod1.setConstructor(false); getMethod1.setVisibility(JavaVisibility.PUBLIC); getMethod1.setStatic(false); getMethod1.setName(dbFieldName); getMethod1.addBodyLine("return "+dbFieldName+";"); getMethod1.setReturnType(new FullyQualifiedJavaType("String")); enum1.addMethod(getMethod1); topLevelClass.addInnerEnum(enum1); } }
Example #11
Source File: MyMapperCommentGenerator.java From jvue-admin with MIT License | 4 votes |
@Override public void addEnumComment(InnerEnum innerEnum, IntrospectedTable introspectedTable) { }
Example #12
Source File: CommentGenerator.java From mybatis-generator-plus with Apache License 2.0 | 4 votes |
public void addEnumComment(InnerEnum innerEnum, IntrospectedTable introspectedTable);
Example #13
Source File: CommentGenerator.java From mapper-generator-javafx with Apache License 2.0 | 2 votes |
/** * Adds the enum comment. * * @param innerEnum * the inner enum * @param introspectedTable * the introspected table */ void addEnumComment(InnerEnum innerEnum, IntrospectedTable introspectedTable);
Example #14
Source File: IModelColumnPluginHook.java From mybatis-generator-plugin with Apache License 2.0 | 2 votes |
/** * Model Column 枚举生成 * @param innerEnum * @param topLevelClass * @param introspectedTable * @return */ boolean modelColumnEnumGenerated(InnerEnum innerEnum, TopLevelClass topLevelClass, IntrospectedTable introspectedTable);
Example #15
Source File: CommentGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 2 votes |
/** * Adds the enum comment. * * @param innerEnum * the inner enum * @param introspectedTable * the introspected table */ public void addEnumComment(InnerEnum innerEnum, IntrospectedTable introspectedTable);