private void addFactoryMethodToCriteria(TopLevelClass topLevelClass, InnerClass innerClass, IntrospectedTable introspectedTable) {
        // example field
        Field exampleField = JavaElementGeneratorTools.generateField(
                "example",
                JavaVisibility.PRIVATE,
                topLevelClass.getType(),
                null
        );
        commentGenerator.addFieldComment(exampleField, introspectedTable);
        innerClass.addField(exampleField);

        // overwrite constructor
        List<Method> methods = innerClass.getMethods();
        for (Method method : methods) {
            if (method.isConstructor()) {
                method.addParameter(new Parameter(topLevelClass.getType(), "example"));
                method.addBodyLine("this.example = example;");
                commentGenerator.addGeneralMethodComment(method, introspectedTable);
                logger.debug("itfsw(Example增强插件):" + topLevelClass.getType().getShortName() + "修改构造方法，增加example参数");
            }
        }

        // 添加example工厂方法
        Method exampleMethod = JavaElementGeneratorTools.generateMethod(
                "example",
                JavaVisibility.PUBLIC,
                topLevelClass.getType()
        );
        commentGenerator.addGeneralMethodComment(exampleMethod, introspectedTable);
        exampleMethod = JavaElementGeneratorTools.generateMethodBody(
                exampleMethod,
                "return this.example;"
        );
        FormatTools.addMethodWithBestPosition(innerClass, exampleMethod);
        logger.debug("itfsw(Example增强插件):" + topLevelClass.getType().getShortName() + "." + innerClass.getType().getShortName() + "增加工厂方法example");
    }
private void addFactoryMethodToCriteria(TopLevelClass topLevelClass, InnerClass innerClass, IntrospectedTable introspectedTable) {
        
        Field exampleField = JavaElementGeneratorTools.generateField(
                "example",
                JavaVisibility.PRIVATE,
                topLevelClass.getType(),
                null
        );
        commentGenerator.addFieldComment(exampleField, introspectedTable);
        innerClass.addField(exampleField);

        
        List<Method> methods = innerClass.getMethods();
        for (Method method : methods) {
            if (method.isConstructor()) {
                method.addParameter(new Parameter(topLevelClass.getType(), "example"));
                method.addBodyLine("this.example = example;");
                commentGenerator.addGeneralMethodComment(method, introspectedTable);
                logger.debug("itfsw(Example增强插件):" + topLevelClass.getType().getShortName() + "修改构造方法，增加example参数");
            }
        }

        
        Method exampleMethod = JavaElementGeneratorTools.generateMethod(
                "example",
                JavaVisibility.PUBLIC,
                topLevelClass.getType()
        );
        commentGenerator.addGeneralMethodComment(exampleMethod, introspectedTable);
        exampleMethod = JavaElementGeneratorTools.generateMethodBody(
                exampleMethod,
                "return this.example;"
        );
        FormatTools.addMethodWithBestPosition(innerClass, exampleMethod);
        logger.debug("itfsw(Example增强插件):" + topLevelClass.getType().getShortName() + "." + innerClass.getType().getShortName() + "增加工厂方法example");
    }
private void addFactoryMethodToCriteria ( TopLevelClass topLevelClass , InnerClass innerClass , IntrospectedTable introspectedTable ) { // example field Field exampleField = JavaElementGeneratorTools . generateField ( "example" , JavaVisibility . PRIVATE , topLevelClass . getType ( ) , null ) ; commentGenerator . addFieldComment ( exampleField , introspectedTable ) ; innerClass . addField ( exampleField ) ; // overwrite constructor List < Method > methods = innerClass . getMethods ( ) ; for ( Method method : methods ) { if ( method . isConstructor ( ) ) { method . addParameter ( new Parameter ( topLevelClass . getType ( ) , "example" ) ) ; method . addBodyLine ( "this.example = example;" ) ; commentGenerator . addGeneralMethodComment ( method , introspectedTable ) ; logger . debug ( "itfsw(Example增强插件):" + topLe e Class.getType ( ).getSh o r t Name() + "修改 构 造 法 增加example参数"); } } // 添加example工厂方法 Method exampleMethod = JavaElementGeneratorTools . generateMethod ( "example" , JavaVisibility . PUBLIC , topLevelClass . getType ( ) ) ; commentGenerator . addGeneralMethodComment ( exampleMethod , introspectedTable ) ; exampleMethod = JavaElementGeneratorTools . generateMethodBody ( exampleMethod , "return this.example;" ) ; FormatTools . addMethodWithBestPosition ( innerClass , exampleMethod ) ; logger . debug ( "itfsw(Example增强插件):" + topLe e Class.getType ( ).getSh o r t Name() + "." + i ner l ss.getType ( ).getSh o r t Name() + "增加 工 厂 法 xample"); }
添加工厂方法
@param topLevelClass
@param innerClass
@param introspectedTable
添加工厂方法