src/main/java/com/itfsw/mybatis/generator/plugins/IncrementsPlugin.java
private boolean lombokBuilderClassGenerated(TopLevelClass topLevelClass, List<IntrospectedColumn> columns, IntrospectedTable introspectedTable) {
        if (this.support()) {
            boolean find = false;
            for (IntrospectedColumn column : columns) {
                if (this.supportColumn(column)) {
                    find = true;
                    break;
                }
            }
            if (find) {
                // ----------------------------------- topLevelClass 方法 --------------------------------
                FullyQualifiedJavaType builderType = new FullyQualifiedJavaType(topLevelClass.getType().getShortName() + "." + topLevelClass.getType().getShortName() + "Builder");
                builderType.addTypeArgument(new SpecTypeArgumentsFullyQualifiedJavaType("<?, ?>"));

                // 增加构造函数
                Method constructor = new Method(topLevelClass.getType().getShortName());
                commentGenerator.addGeneralMethodComment(constructor, introspectedTable);
                constructor.setVisibility(JavaVisibility.PROTECTED);
                constructor.setConstructor(true);
                constructor.addParameter(new Parameter(builderType, "builder"));
                // 是否调用父类构造函数
                if (topLevelClass.getSuperClass() != null) {
                    constructor.addBodyLine("super(builder);");
                }
                for (IntrospectedColumn column : columns) {
                    Field field = JavaBeansUtil.getJavaBeansField(column, context, introspectedTable);
                    constructor.addBodyLine("this." + field.getName() + " = builder." + field.getName() + ";");
                }
                FormatTools.addMethodWithBestPosition(topLevelClass, constructor);

                // 增加静态builder方法实现和lombok一样
                Method builderMethod = JavaElementGeneratorTools.generateMethod(
                        "builder",
                        JavaVisibility.PUBLIC,
                        builderType
                );
                commentGenerator.addGeneralMethodComment(builderMethod, introspectedTable);
                builderMethod.setStatic(true);
                builderMethod.addBodyLine("return new " + topLevelClass.getType().getShortName() + "." + topLevelClass.getType().getShortName() + "BuilderImpl();");
                FormatTools.addMethodWithBestPosition(topLevelClass, builderMethod);

                // ------------------------------ builder Class ----------------------------------
                InnerClass builderCls = new InnerClass(topLevelClass.getType().getShortName() + "Builder");
                commentGenerator.addClassComment(builderCls, introspectedTable);
                builderCls.setVisibility(JavaVisibility.PUBLIC);
                builderCls.setStatic(true);
                builderCls.setAbstract(true);

                builderCls.getType().addTypeArgument(
                        new SpecTypeArgumentsFullyQualifiedJavaType("<C extends " + topLevelClass.getType().getShortName()
                                + ", B extends " + topLevelClass.getType().getShortName()
                                + "." + topLevelClass.getType().getShortName() + "Builder<C, B>>")
                );

                if (topLevelClass.getSuperClass() != null) {
                    FullyQualifiedJavaType superBuilderCls = new FullyQualifiedJavaType(topLevelClass.getSuperClass().getShortName() + "Builder");
                    superBuilderCls.addTypeArgument(new SpecTypeArgumentsFullyQualifiedJavaType("<C, B>"));
                    builderCls.setSuperClass(superBuilderCls);
                }

                // 类注解
                topLevelClass.addImportedType(LombokPlugin.EnumLombokAnnotations.SETTER.getClazz());
                builderCls.addAnnotation(LombokPlugin.EnumLombokAnnotations.SETTER.getAnnotation());
                topLevelClass.addImportedType(LombokPlugin.EnumLombokAnnotations.ACCESSORS_FLUENT_TRUE.getClazz());
                builderCls.addAnnotation(LombokPlugin.EnumLombokAnnotations.ACCESSORS_FLUENT_TRUE.getAnnotation());
                if (topLevelClass.getSuperClass() != null) {
                    topLevelClass.addImportedType(LombokPlugin.EnumLombokAnnotations.TO_STRING_CALL_SUPER.getClazz());
                    builderCls.addAnnotation(LombokPlugin.EnumLombokAnnotations.TO_STRING_CALL_SUPER.getAnnotation());
                } else {
                    topLevelClass.addImportedType(LombokPlugin.EnumLombokAnnotations.TO_STRING.getClazz());
                    builderCls.addAnnotation(LombokPlugin.EnumLombokAnnotations.TO_STRING.getAnnotation());
                }


                for (IntrospectedColumn introspectedColumn : columns) {
                    Field field = JavaBeansUtil.getJavaBeansField(introspectedColumn, context, introspectedTable);
                    field.getJavaDocLines().clear();
                    commentGenerator.addFieldComment(field, introspectedTable);

                    builderCls.addField(field);
                }

                // self 方法
                Method selfMethod1 = JavaElementGeneratorTools.generateMethod(
                        "self",
                        JavaVisibility.PROTECTED,
                        new FullyQualifiedJavaType("B")
                );
                commentGenerator.addGeneralMethodComment(selfMethod1, introspectedTable);
                FormatTools.addMethodWithBestPosition(builderCls, selfMethod1);

                // build 方法
                Method buildMethod1 = JavaElementGeneratorTools.generateMethod(
                        "build",
                        JavaVisibility.PUBLIC,
                        new FullyQualifiedJavaType("C")
                );
                commentGenerator.addGeneralMethodComment(buildMethod1, introspectedTable);
                FormatTools.addMethodWithBestPosition(builderCls, buildMethod1);


                topLevelClass.addInnerClass(builderCls);


                // --------------------------------- 生成自增插件需要的方法 --------------------------------------
                // 增加枚举
                if (this.incEnum == null) {
                    this.incEnum = this.generatedIncEnum(introspectedTable);
                    this.incEnumBuilder = builderCls;

                    builderCls.addInnerEnum(this.incEnum);
                    // topLevel class 添加必要的操作方法
                    this.addIncMethodToTopLevelClass(topLevelClass, builderCls, introspectedTable, true);

                    // Builder 中 添加字段支持
                    Field fIncrements = JavaElementGeneratorTools.generateField(
                            IncrementsPlugin.FIELD_INC_MAP,
                            JavaVisibility.PROTECTED,
                            new FullyQualifiedJavaType("Map<String, " + this.getIncEnum(builderCls, introspectedTable).getFullyQualifiedName() + ">"),
                            "new HashMap<String, " + this.getIncEnum(builderCls, introspectedTable).getFullyQualifiedName() + ">()"
                    );
                    commentGenerator.addFieldComment(fIncrements, introspectedTable);
                    builderCls.addField(fIncrements);

                    // Builder 构造函数增加 自增Map
                    constructor.addBodyLine("this." + IncrementsPlugin.FIELD_INC_MAP + ".putAll(builder." + IncrementsPlugin.FIELD_INC_MAP + ");");
                }

                FullyQualifiedJavaType builderType2 = new FullyQualifiedJavaType(topLevelClass.getType().getShortName() + "." + topLevelClass.getType().getShortName() + "Builder");
                builderType2.addTypeArgument(new SpecTypeArgumentsFullyQualifiedJavaType("<C, B>"));
                for (IntrospectedColumn column : columns) {
                    if (this.supportColumn(column)) {
                        Field field = JavaBeansUtil.getJavaBeansField(column, context, introspectedTable);
                        // 增加方法
                        Method mIncrements = JavaElementGeneratorTools.generateMethod(
                                field.getName(),
                                JavaVisibility.PUBLIC,
                                builderType2,
                                new Parameter(field.getType(), field.getName()),
                                new Parameter(this.getIncEnum(builderCls, introspectedTable), "inc")
                        );
                        commentGenerator.addSetterComment(mIncrements, introspectedTable, column);
                        mIncrements.addBodyLine("this." + IncrementsPlugin.FIELD_INC_MAP + ".put(\"" + column.getActualColumnName() + "\", inc);");
                        mIncrements.addBodyLine("return this." + field.getName() + "(" + field.getName() + ");");

                        FormatTools.addMethodWithBestPosition(builderCls, mIncrements);
                    }
                }

                // ------------------------------ builderImpl Class ----------------------------------
                InnerClass builderImplCls = new InnerClass(topLevelClass.getType().getShortName() + "BuilderImpl");
                commentGenerator.addClassComment(builderImplCls, introspectedTable);
                FullyQualifiedJavaType builderType1 = new FullyQualifiedJavaType(topLevelClass.getType().getShortName() + "." + topLevelClass.getType().getShortName() + "Builder");
                builderType1.addTypeArgument(new SpecTypeArgumentsFullyQualifiedJavaType(
                        "<" + topLevelClass.getType().getShortName() + ", " + topLevelClass.getType().getShortName() + "." + topLevelClass.getType().getShortName() + "BuilderImpl" + ">"
                ));
                builderImplCls.setSuperClass(builderType1);
                builderImplCls.setVisibility(JavaVisibility.PRIVATE);
                builderImplCls.setFinal(true);
                builderImplCls.setStatic(true);

                topLevelClass.addInnerClass(builderImplCls);

                // self 方法
                Method selfMethod = JavaElementGeneratorTools.generateMethod(
                        "self",
                        JavaVisibility.PROTECTED,
                        new FullyQualifiedJavaType(topLevelClass.getType().getShortName() + "." + topLevelClass.getType().getShortName() + "BuilderImpl")
                );
                commentGenerator.addGeneralMethodComment(selfMethod, introspectedTable);
                selfMethod.addBodyLine("return this;");
                FormatTools.addMethodWithBestPosition(builderImplCls, selfMethod);

                // build 方法
                Method buildMethod = JavaElementGeneratorTools.generateMethod(
                        "build",
                        JavaVisibility.PUBLIC,
                        topLevelClass.getType()
                );
                commentGenerator.addGeneralMethodComment(buildMethod, introspectedTable);
                buildMethod.addBodyLine("return new " + topLevelClass.getType().getShortName() + "(this);");
                FormatTools.addMethodWithBestPosition(builderImplCls, buildMethod);

                return false;
            }
        }
        return true;
    }
private boolean lombokBuilderClassGenerated(TopLevelClass topLevelClass, List<IntrospectedColumn> columns, IntrospectedTable introspectedTable) {
        if (this.support()) {
            boolean find = false;
            for (IntrospectedColumn column : columns) {
                if (this.supportColumn(column)) {
                    find = true;
                    break;
                }
            }
            if (find) {
                // ----------------------------------- topLevelClass 方法 --------------------------------
                FullyQualifiedJavaType builderType = new FullyQualifiedJavaType(topLevelClass.getType().getShortName() + "." + topLevelClass.getType().getShortName() + "Builder");
                builderType.addTypeArgument(new SpecTypeArgumentsFullyQualifiedJavaType("<?, ?>"));

                // 增加构造函数
                Method constructor = new Method(topLevelClass.getType().getShortName());
                commentGenerator.addGeneralMethodComment(constructor, introspectedTable);
                constructor.setVisibility(JavaVisibility.PROTECTED);
                constructor.setConstructor(true);
                constructor.addParameter(new Parameter(builderType, "builder"));
                // 是否调用父类构造函数
                if (topLevelClass.getSuperClass() != null) {
                    constructor.addBodyLine("super(builder);");
                }
                for (IntrospectedColumn column : columns) {
                    Field field = JavaBeansUtil.getJavaBeansField(column, context, introspectedTable);
                    constructor.addBodyLine("this." + field.getName() + " = builder." + field.getName() + ";");
                }
                FormatTools.addMethodWithBestPosition(topLevelClass, constructor);

                // 增加静态builder方法实现和lombok一样
                Method builderMethod = JavaElementGeneratorTools.generateMethod(
                        "builder",
                        JavaVisibility.PUBLIC,
                        builderType
                );
                commentGenerator.addGeneralMethodComment(builderMethod, introspectedTable);
                builderMethod.setStatic(true);
                builderMethod.addBodyLine("return new " + topLevelClass.getType().getShortName() + "." + topLevelClass.getType().getShortName() + "BuilderImpl();");
                FormatTools.addMethodWithBestPosition(topLevelClass, builderMethod);

                // ------------------------------ builder Class ----------------------------------
                InnerClass builderCls = new InnerClass(topLevelClass.getType().getShortName() + "Builder");
                commentGenerator.addClassComment(builderCls, introspectedTable);
                builderCls.setVisibility(JavaVisibility.PUBLIC);
                builderCls.setStatic(true);
                builderCls.setAbstract(true);

                builderCls.getType().addTypeArgument(
                        new SpecTypeArgumentsFullyQualifiedJavaType("<C extends " + topLevelClass.getType().getShortName()
                                + ", B extends " + topLevelClass.getType().getShortName()
                                + "." + topLevelClass.getType().getShortName() + "Builder<C, B>>")
                );

                if (topLevelClass.getSuperClass() != null) {
                    FullyQualifiedJavaType superBuilderCls = new FullyQualifiedJavaType(topLevelClass.getSuperClass().getShortName() + "Builder");
                    superBuilderCls.addTypeArgument(new SpecTypeArgumentsFullyQualifiedJavaType("<C, B>"));
                    builderCls.setSuperClass(superBuilderCls);
                }

                // 类注解
                topLevelClass.addImportedType(LombokPlugin.EnumLombokAnnotations.SETTER.getClazz());
                builderCls.addAnnotation(LombokPlugin.EnumLombokAnnotations.SETTER.getAnnotation());
                topLevelClass.addImportedType(LombokPlugin.EnumLombokAnnotations.ACCESSORS_FLUENT_TRUE.getClazz());
                builderCls.addAnnotation(LombokPlugin.EnumLombokAnnotations.ACCESSORS_FLUENT_TRUE.getAnnotation());
                if (topLevelClass.getSuperClass() != null) {
                    topLevelClass.addImportedType(LombokPlugin.EnumLombokAnnotations.TO_STRING_CALL_SUPER.getClazz());
                    builderCls.addAnnotation(LombokPlugin.EnumLombokAnnotations.TO_STRING_CALL_SUPER.getAnnotation());
                } else {
                    topLevelClass.addImportedType(LombokPlugin.EnumLombokAnnotations.TO_STRING.getClazz());
                    builderCls.addAnnotation(LombokPlugin.EnumLombokAnnotations.TO_STRING.getAnnotation());
                }


                for (IntrospectedColumn introspectedColumn : columns) {
                    Field field = JavaBeansUtil.getJavaBeansField(introspectedColumn, context, introspectedTable);
                    field.getJavaDocLines().clear();
                    commentGenerator.addFieldComment(field, introspectedTable);

                    builderCls.addField(field);
                }

                // self 方法
                Method selfMethod1 = JavaElementGeneratorTools.generateMethod(
                        "self",
                        JavaVisibility.PROTECTED,
                        new FullyQualifiedJavaType("B")
                );
                commentGenerator.addGeneralMethodComment(selfMethod1, introspectedTable);
                FormatTools.addMethodWithBestPosition(builderCls, selfMethod1);

                // build 方法
                Method buildMethod1 = JavaElementGeneratorTools.generateMethod(
                        "build",
                        JavaVisibility.PUBLIC,
                        new FullyQualifiedJavaType("C")
                );
                commentGenerator.addGeneralMethodComment(buildMethod1, introspectedTable);
                FormatTools.addMethodWithBestPosition(builderCls, buildMethod1);


                topLevelClass.addInnerClass(builderCls);


                // --------------------------------- 生成自增插件需要的方法 --------------------------------------
                // 增加枚举
                if (this.incEnum == null) {
                    this.incEnum = this.generatedIncEnum(introspectedTable);
                    this.incEnumBuilder = builderCls;

                    builderCls.addInnerEnum(this.incEnum);
                    // topLevel class 添加必要的操作方法
                    this.addIncMethodToTopLevelClass(topLevelClass, builderCls, introspectedTable, true);

                    // Builder 中 添加字段支持
                    Field fIncrements = JavaElementGeneratorTools.generateField(
                            IncrementsPlugin.FIELD_INC_MAP,
                            JavaVisibility.PROTECTED,
                            new FullyQualifiedJavaType("Map<String, " + this.getIncEnum(builderCls, introspectedTable).getFullyQualifiedName() + ">"),
                            "new HashMap<String, " + this.getIncEnum(builderCls, introspectedTable).getFullyQualifiedName() + ">()"
                    );
                    commentGenerator.addFieldComment(fIncrements, introspectedTable);
                    builderCls.addField(fIncrements);

                    // Builder 构造函数增加 自增Map
                    constructor.addBodyLine("this." + IncrementsPlugin.FIELD_INC_MAP + ".putAll(builder." + IncrementsPlugin.FIELD_INC_MAP + ");");
                }

                FullyQualifiedJavaType builderType2 = new FullyQualifiedJavaType(topLevelClass.getType().getShortName() + "." + topLevelClass.getType().getShortName() + "Builder");
                builderType2.addTypeArgument(new SpecTypeArgumentsFullyQualifiedJavaType("<C, B>"));
                for (IntrospectedColumn column : columns) {
                    if (this.supportColumn(column)) {
                        Field field = JavaBeansUtil.getJavaBeansField(column, context, introspectedTable);
                        // 增加方法
                        Method mIncrements = JavaElementGeneratorTools.generateMethod(
                                field.getName(),
                                JavaVisibility.PUBLIC,
                                builderType2,
                                new Parameter(field.getType(), field.getName()),
                                new Parameter(this.getIncEnum(builderCls, introspectedTable), "inc")
                        );
                        commentGenerator.addSetterComment(mIncrements, introspectedTable, column);
                        mIncrements.addBodyLine("this." + IncrementsPlugin.FIELD_INC_MAP + ".put(\"" + column.getActualColumnName() + "\", inc);");
                        mIncrements.addBodyLine("return this." + field.getName() + "(" + field.getName() + ");");

                        FormatTools.addMethodWithBestPosition(builderCls, mIncrements);
                    }
                }

                // ------------------------------ builderImpl Class ----------------------------------
                InnerClass builderImplCls = new InnerClass(topLevelClass.getType().getShortName() + "BuilderImpl");
                commentGenerator.addClassComment(builderImplCls, introspectedTable);
                FullyQualifiedJavaType builderType1 = new FullyQualifiedJavaType(topLevelClass.getType().getShortName() + "." + topLevelClass.getType().getShortName() + "Builder");
                builderType1.addTypeArgument(new SpecTypeArgumentsFullyQualifiedJavaType(
                        "<" + topLevelClass.getType().getShortName() + ", " + topLevelClass.getType().getShortName() + "." + topLevelClass.getType().getShortName() + "BuilderImpl" + ">"
                ));
                builderImplCls.setSuperClass(builderType1);
                builderImplCls.setVisibility(JavaVisibility.PRIVATE);
                builderImplCls.setFinal(true);
                builderImplCls.setStatic(true);

                topLevelClass.addInnerClass(builderImplCls);

                // self 方法
                Method selfMethod = JavaElementGeneratorTools.generateMethod(
                        "self",
                        JavaVisibility.PROTECTED,
                        new FullyQualifiedJavaType(topLevelClass.getType().getShortName() + "." + topLevelClass.getType().getShortName() + "BuilderImpl")
                );
                commentGenerator.addGeneralMethodComment(selfMethod, introspectedTable);
                selfMethod.addBodyLine("return this;");
                FormatTools.addMethodWithBestPosition(builderImplCls, selfMethod);

                // build 方法
                Method buildMethod = JavaElementGeneratorTools.generateMethod(
                        "build",
                        JavaVisibility.PUBLIC,
                        topLevelClass.getType()
                );
                commentGenerator.addGeneralMethodComment(buildMethod, introspectedTable);
                buildMethod.addBodyLine("return new " + topLevelClass.getType().getShortName() + "(this);");
                FormatTools.addMethodWithBestPosition(builderImplCls, buildMethod);

                return false;
            }
        }
        return true;
    }
Lombok Builder 生成
@param topLevelClass
@param columns
@param introspectedTable
@return