annotations

Using annotations and AST transforms in Groovy classes.

Groovy Custom Annotations – Create Your Own with 10 Tested Examples

Groovy custom annotations are versatile. See 10 tested examples covering annotation declaration, retention policies, AST transformations, and runtime processing. “Annotations are metadata that give your code a voice – they tell the compiler, the runtime, and other developers what your intentions are without cluttering your logic.” Joshua Bloch, Effective Java Last Updated: March 2026 | Tested on: Groovy 4.x / 5.x, Java 11+ | Difficulty: Advanced | Reading Time: 18 minutes Groovy ships with a rich set of built-in annotations ... Read More

Groovy AST Transformations – Compile-Time Code Generation with 10+ Examples

Groovy AST transformations for compile-time code generation. 10+ examples covering @ToString, @EqualsAndHashCode, @Canonical, @Delegate, and custom ASTs. “The best code is code you never write. AST transformations generate boilerplate at compile time so you can focus on what matters.” Groovy Metaprogramming Philosophy Last Updated: March 2026 | Tested on: Groovy 5.x, Java 17+ | Difficulty: Intermediate to Advanced | Reading Time: 20 minutes Every developer knows the pain of writing toString(), equals(), hashCode(), constructors, and getters/setters for every class. It’s ... Read More