Creates a new Writer instance with the specified configuration.
The configuration for the writer
Increases the current indentation level by one. Used for proper code formatting.
Decreases the current indentation level by one. Used for proper code formatting.
Writes text to the buffer without adding a new line.
The text to write
Writes a line of text to the buffer with proper indentation. If no text is provided, only writes a new line.
Optional
text: stringThe text to write (optional)
Adds a new line to the buffer.
Adds a new line to the buffer only if the last character isn't already a new line. This prevents multiple consecutive empty lines.
Adds a class reference to be imported. References from the same package are not added.
The class reference to add
Adds an import statement to the list of imports.
The full import path
Generates the final Java code with imports and package declaration.
The complete Java code as a string
Formats the output code to have consistent spacing.
The code to format
The formatted code
The Writer class is responsible for writing Java code with proper formatting. It handles indentation, imports, and provides utility methods for writing code. This class is the core component for generating properly formatted Java source code.
Implements