Using Groovy Code-Generation Transformations

Groovy tactfully eases the tension that language designers often face between a desire to evolve the language and a reluctance to modify the grammar due to its impact on performance, complexity, and semantic correctness. Rather than modifying the core syntax of the language, the Groovy compiler recognizes select annotations and generates appropriate code. In this section you’ll learn about a few such annotations. Chapter 16, Applying Compile-Time Metaprogramming, covers how to create our own annotations for custom transformations.

Groovy provides a number of code-generation annotations in the groovy.transform package and a few other packages. We’ll talk about a few of these annotations in this section. ...

Get Programming Groovy 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.