A Java API for generating .java source files programmatically, useful for annotation processing and code generation.
JavaPoet is a Java library that enables programmatic generation of `.java` source files. It provides a fluent API to create classes, methods, fields, and other code structures, making it ideal for scenarios like annotation processing or generating code from metadata. By automating boilerplate, it helps maintain consistency and reduces manual errors.
Java developers working on annotation processors, code generation tools, or projects that need to produce Java source files dynamically from schemas, protocols, or other metadata.
JavaPoet offers a type-safe, readable, and composable API that handles formatting and imports automatically, unlike string concatenation or templating. It generates clean, reviewable source code and is designed as a successor to JavaWriter with better type modeling and import management.
A Java API for generating .java source files.
Uses method chaining and immutable objects like MethodSpec and TypeSpec builders, making code generation intuitive and less error-prone than string concatenation, as demonstrated in the HelloWorld example.
Supports $T placeholders for types with automatic import handling, simplifying the generation of correct Java files and reducing manual import errors.
Provides beginControlFlow() and endControlFlow() methods to easily generate loops, conditionals, and try-catch blocks, as shown in examples for if/else and for loops.
Covers a wide range of Java constructs including classes, interfaces, enums, annotations, and Javadoc, allowing for diverse code generation needs.
Square has officially deprecated the project since 2020, meaning no updates, bug fixes, or support for newer Java versions, forcing users to switch to forks like Palantir's.
Relies on raw strings for method bodies and expressions, which can lead to syntax errors and lacks the type safety of a structured abstract syntax tree, as admitted in the 'Code & Control Flow' section.
Switching to the recommended Palantir fork requires changes in Maven coordinates, imports, and API usage (e.g., packageName to packageName()), adding complexity for existing projects.
JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
GraalVM compiles applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
A collection of source code generators for Java.
Catch common Java mistakes as compile-time errors
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.