Groovy @Canonical: Generate Value-Object Boilerplate at Compile Time
Use @groovy.transform.Canonical to generate getters, setters, equals, hashCode, and toString for Groovy classes without writing them by hand.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Use @groovy.transform.Canonical to generate getters, setters, equals, hashCode, and toString for Groovy classes without writing them by hand.
Boost Groovy performance in computation-heavy code by using @CompileStatic. Learn the trade-offs between dynamic flexibility and predictable, fast static compilation.
Use Groovy’s @Canonical annotation to automatically generate equals, hashCode, toString and a copy method for a simple value object, then verify with compilation and unit tests while watching for mutable‑field pitfalls.
Architecture note on Groovy @CompileStatic: when to enable static compilation, how to draw trust boundaries between dynamic and static code, operational CI guards, and failure modes that require mitigation.
Architecture note on using Groovy closures for DSLs: delegate scoping, static compilation trade‑offs, memory‑leak guards, and operational checks with concrete code and benchmark commands.
Use Groovy’s @CompileStatic to enable compile‑time type checking and Java‑like bytecode for faster, safer code. Learn how, with a factorial example, the limits, common pitfalls, and verification steps to ensure success.
Grails services are transactional by default, but @Transactional can be too coarse. GORM's withTransaction gives you programmatic control for conditional commits, nested logic, and retry scenarios—if you understand its rollback rules and nesting quirks.
Groovy’s GString interpolation with the Sql class lets you write concise, readable queries that are automatically bound as parameters, preventing injection. Learn how it works, see a hands‑on example, and understand trade‑offs and best practices.
Learn how Groovy closures capture lexical scope and use the delegate property to build DSLs. This guide covers variable reference behavior, resolve strategies, and performance trade-offs.