O'Reilly logo

Groovy and Grails Recipes by Bashar Abdul-Jawad

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 6Builders

Builders are a fine example of Groovy's dynamic capabilities. By using builders, you can build treelike structures, where your code resembles the structure you are trying to build. Treelike structures are common constructs in applications. File systems, HTML and XML documents, GUIs, and any other hierarchical structure that can be represented as a tree of connected nodes are examples of treelike structures. Groovy enables you to avoid any code duplication when building such structures, and by looking at the resulting code, you can easily visualize the structure you are trying to build. This chapter introduces you to the different kinds of builders that Groovy offers and shows you how to write your own builder.

6-1. What Are ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required