O'Reilly logo

Programming Groovy 2 by Venkat Subramaniam

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

Using Object Extensions

In this section, we’ll explore some additions to the mother of all classes, the java.lang.Object class. In Chapter 6, Working with Collections, we saw Groovy-added methods on Collections: each, collect, find, findAll, any, and every. These are not only available on Collections; we can also use these methods on any object. This gives us a consistent API to work with individual objects and collections alike—one of the benefits elicited in the Composite pattern (see Design Patterns: Elements of Reusable Object-Oriented Software [GHJV95]). Groovy has added non-collections-related convenience methods to Object, as well. We won’t go over all of those in this section—we don’t want this chapter to turn into a complete reference ...

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