public int generateFiles()
    {
        List<URL> allTemplateFilesFromClassPath = FileUtils.getAllTemplateFilesFromClasspath(this.templateDirectory, this.classPathURLs);
        for (URL url : allTemplateFilesFromClassPath)
        {
            this.url = url;
            this.templateFile = new STGroupFile(this.url, "UTF-8", '<', '>');
            this.templateFile.setListener(this.stErrorListener);
            this.templateFile.registerRenderer(String.class, new IntegerOrStringRenderer());
            if (this.templateFile.isDefined("fileName"))
            {
                this.setTest();
                File targetPath = this.constructTargetPath();
                FileUtils.createDirectory(targetPath);

                boolean hasTwoPrimitives = this.templateFile.isDefined("hasTwoPrimitives") && Boolean.valueOf(this.templateFile.getInstanceOf("hasTwoPrimitives").render());
                boolean skipBoolean = this.templateFile.isDefined("skipBoolean") && Boolean.valueOf(this.templateFile.getInstanceOf("skipBoolean").render());
                boolean skipBooleanKeys = this.templateFile.isDefined("skipBooleanKeys") && Boolean.valueOf(this.templateFile.getInstanceOf("skipBooleanKeys").render());

                if (hasTwoPrimitives)
                {
                    for (Primitive primitive1 : Primitive.values())
                    {
                        if (primitive1 == Primitive.BOOLEAN && (skipBoolean || skipBooleanKeys))
                        {
                            continue;
                        }
                        for (Primitive primitive2 : Primitive.values())
                        {
                            if (primitive2 == Primitive.BOOLEAN && skipBoolean)
                            {
                                continue;
                            }
                            String sourceFileName = this.executeTemplate(primitive1, primitive2, "fileName");
                            File outputFile = new File(targetPath, sourceFileName + ".java");

                            if (!GsCollectionsCodeGenerator.sourceFileExists(outputFile))
                            {
                                String classContents = this.executeTemplate(primitive1, primitive2, "class");
                                this.checkSumClassContentsAndWrite(classContents, targetPath, sourceFileName);
                            }
                        }
                    }
                }
                else
                {
                    for (Primitive primitive : Primitive.values())
                    {
                        if (primitive == Primitive.BOOLEAN && skipBoolean)
                        {
                            continue;
                        }
                        String sourceFileName = this.executeTemplate(primitive, "fileName");
                        File outputFile = new File(targetPath, sourceFileName + ".java");

                        if (!GsCollectionsCodeGenerator.sourceFileExists(outputFile))
                        {
                            String classContents = this.executeTemplate(primitive, "class");
                            this.checkSumClassContentsAndWrite(classContents, targetPath, sourceFileName);
                        }
                    }
                }
            }
        }

        return this.numFileWritten;
    }
public int generateFiles ( ) { List < URL > allTemplateFilesFromClassPath = FileUtils . getAllTemplateFilesFromClasspath ( this . templateDirectory , this . classPathURLs ) ; for ( URL url : allTemplateFilesFromClassPath ) { this . url = url ; this . templateFile = new STGroupFile ( this . url , "UTF-8" , '<' , '>' ) ; this . templateFile . setListener ( this . stErrorListener ) ; this . templateFile . registerRenderer ( String . class , new IntegerOrStringRenderer ( ) ) ; if ( this . templateFile . isDefined ( "fileName" ) ) { this . setTest ( ) ; File targetPath = this . constructTargetPath ( ) ; FileUtils . createDirectory ( targetPath ) ; boolean hasTwoPrimitives = this . templateFile . isDefined ( "hasTwoPrimitives" ) && Boolean . valueOf ( this . templateFile . getInstanceOf ( "hasTwoPrimitives" ) . render ( ) ) ; boolean skipBoolean = this . templateFile . isDefined ( "skipBoolean" ) && Boolean . valueOf ( this . templateFile . getInstanceOf ( "skipBoolean" ) . render ( ) ) ; boolean skipBooleanKeys = this . templateFile . isDefined ( "skipBooleanKeys" ) && Boolean . valueOf ( this . templateFile . getInstanceOf ( "skipBooleanKeys" ) . render ( ) ) ; if ( hasTwoPrimitives ) { for ( Primitive primitive1 : Primitive . values ( ) ) { if ( primitive1 == Primitive . BOOLEAN && ( skipBoolean || skipBooleanKeys ) ) { continue ; } for ( Primitive primitive2 : Primitive . values ( ) ) { if ( primitive2 == Primitive . BOOLEAN && skipBoolean ) { continue ; } String sourceFileName = this . executeTemplate ( primitive1 , primitive2 , "fileName" ) ; File outputFile = new File ( targetPath , sourceFileName + ".java" ) ; if ( ! GsCollectionsCodeGenerator . sourceFileExists ( outputFile ) ) { String classContents = this . executeTemplate ( primitive1 , primitive2 , "class" ) ; this . checkSumClassContentsAndWrite ( classContents , targetPath , sourceFileName ) ; } } } } else { for ( Primitive primitive : Primitive . values ( ) ) { if ( primitive == Primitive . BOOLEAN && skipBoolean ) { continue ; } String sourceFileName = this . executeTemplate ( primitive , "fileName" ) ; File outputFile = new File ( targetPath , sourceFileName + ".java" ) ; if ( ! GsCollectionsCodeGenerator . sourceFileExists ( outputFile ) ) { String classContents = this . executeTemplate ( primitive , "class" ) ; this . checkSumClassContentsAndWrite ( classContents , targetPath , sourceFileName ) ; } } } } } return this . numFileWritten ; }
Generates code and only write contents to disk which differ from the current file contents.

@return The number of files written.