closures

Groovy closure syntax, usage patterns, and functional programming.

Groovy Advanced AST Transforms – Part 2 with 10+ Examples

Groovy advanced AST transforms beyond @ToString and @Canonical. Part 2 covers @TupleConstructor, @MapConstructor, @Delegate, @Memoized, @AutoClone, @Sortable, @Newify, and combining multiple transforms. “The best boilerplate is the boilerplate you never write. AST transformations are your compiler doing your chores.” Last Updated: July 2026 | Tested on: Groovy 5.0.6, Java 17+ | Difficulty: Intermediate | Reading Time: 20 minutes This is Part 2 of our AST transformations series. Part 1 covered the essentials – @ToString, @EqualsAndHashCode, @Canonical, @Immutable, and @Builder. Those ... Read More

Groovy Idiomatic Patterns – Category, Delegation, and Closure Patterns

Groovy idiomatic patterns that have no Java equivalent. 12 tested examples covering Category, @Delegate, closure-based DSLs, builder patterns, method chaining, and patterns that only work because Groovy is Groovy. “Design patterns are not about memorizing class diagrams – they’re about recognizing recurring problems. In Groovy, half the GoF patterns collapse into a closure and a map.” Last Updated: July 2026 | Tested on: Groovy 5.0.6, Java 17+ | Difficulty: Intermediate | Reading Time: 20 minutes Our Groovy Design Patterns post ... Read More

Groovy Interfaces – Contracts and Polymorphism with 10 Tested Examples

Every mock in your Spock suite, every Gradle task type, every plugin point in a Java shop rests on the same idea: code agreeing on a contract without sharing an implementation. Get comfortable with that idea and half of JVM design falls into place. This guide covers Groovy interfaces end to end: declarations, default methods, SAM types, and closure coercion, through 10 examples tested on Groovy 5.0.6. “Program to an interface, not an implementation.” Gamma, Helm, Johnson, Vlissides, Design Patterns ... Read More