Chapter 10. Building a Builder

Builders are a powerful feature of Groovy. The Groovy libraries contain an expanding set of builders for everything from XML and HTML markup to managing systems via JMX. Even so, you will always come across circumstances where the semantics of a builder would be useful in your own application.

We've seen how to build a rudimentary builder using the Groovy MOP and pretended methods, in Chapter 7, Power Groovy DSL Features. Thankfully, the Groovy libraries provide us with an easier means of developing our own builders. In this chapter, we will look at some of the ways in which we can use Groovy and the MOP to create our own builder classes:

  • To begin with, we will recap the Groovy features that enable the Groovy builder ...

Get Groovy for Domain-specific Languages - Second Edition 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.