17.4 Custom Builder Using Metaprogramming
As we saw earlier, builders provide a way to create an internal DSL for specialized complex tasks that use a nested or hierarchical structure or format. When working with a specialized task in our application, we can check for a builder that can solve the problem. If we don’t find any builders, we can create our own.
We have two ways to create a custom builder: take the entire effort on our shoulders by using
Groovy’s metaprogramming capabilities, as we’ll see in this section, or use the BuilderSupport (Section 17.5, Using BuilderSupport) or FactoryBuilderSupport (Section 17.6, Using FactoryBuilderSupport) Groovy provides.
To help understand the BuilderSupport’s benefits, let’s build a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access