Writing less verbose Java Beans with Groovy Beans
Java Beans are very popular among Java developers. A Java Bean is essentially data with little or no behavior (depending on the implementation). Formally, a Java Bean is a Java class that is serializable, has a public no-argument constructor, private fields, and getter and setter methods for accessing the fields. Often, POJO (Plain Old Java Object) and a Java Bean are used interchangeably.
In this recipe, we will show how Groovy can save you from a lot of typing by offering several features for bean class creation built into the language and API.
Getting ready
A typical Java Bean looks like the following code snippet:
public class Student implements Serializable { private Long id; private String name; ...
Get Groovy 2 Cookbook 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.