Class JavaCodeBuilder
java.lang.Object
com.northconcepts.datapipeline.sourcecode.JavaCodeBuilder
A simple model containing generated Java code, imports, and variable names.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd an import for an individual class.Add an import for an individual class or all all classes in the specified class' package (ifallClassesInPackageis true).Add an import for a package, package wildcard, or individual class.createVariable(String variable) Reserves and returns a unique variable name: the given name if unused, otherwise the name plus the first free suffix from 0 to 99 (throws when all are taken).Returns the package declared in the generated source; classes in it are not imported byaddImport(Class).Returns the package line, the sorted imports and the code body; closes the source writer, so call it once all code is written.Returns the writer for the code body, whichgetSource()places after the package and import lines.setPackage(String packageName) Sets the package declared in the generated source; set it beforeaddImport(Class)so classes in it are not imported.
-
Constructor Details
-
JavaCodeBuilder
public JavaCodeBuilder()
-
-
Method Details
-
getPackage
Returns the package declared in the generated source; classes in it are not imported byaddImport(Class). -
setPackage
Sets the package declared in the generated source; set it beforeaddImport(Class)so classes in it are not imported. -
addImport
Add an import for a package, package wildcard, or individual class. -
addImport
Add an import for an individual class. -
addImport
Add an import for an individual class or all all classes in the specified class' package (ifallClassesInPackageis true). -
getImports
-
createVariable
Reserves and returns a unique variable name: the given name if unused, otherwise the name plus the first free suffix from 0 to 99 (throws when all are taken). -
getSourceWriter
Returns the writer for the code body, whichgetSource()places after the package and import lines. -
getSource
Returns the package line, the sorted imports and the code body; closes the source writer, so call it once all code is written.
-