Java Reference
In-Depth Information
The Groovy JDK
Through its metaprogramming capabilities, Groovy adds many convenient methods to the
standard Java libraries. These additional methods are known as the Groovy JDK.
In summary, Groovy uses numbers and objects and has both regular and parameterized
strings with additional methods. Another area where Groovy greatly simplifies Java is col-
lections.
B.3. Plain Old Groovy Objects
Java classes with getters and setters for the attributes are often known as POJOs, or Plain
Old Java Objects. In Groovy, the same classes are Plain Old Groovy Objects, or POGOs. [ 7 ]
POGOs have additional characteristics that are discussed in this section.
7 Python occasionally uses the term POPOs, which sounds vaguely disgusting. If you really want to annoy a Ruby
developer, refer to POROs. Ruby people hate anything that sounds like Java.
Consider the following Person class in Groovy:
class Person {
String firstName
String lastName
String toString() { "$firstName $lastName" }
}
POGOs don't require access modifiers, because in Groovy attributes are private by default
and methods are public by default. The class is public by default, as well. Any property
withoutanaccessmodifierautomatically getsapublicgetterandsettermethod.Ifyouwant
to add public or private you can, and either on an attribute will prevent the genera-
tion of the associated getter and setter.
Groovy properties
In Groovy, property access is done through dynamically generated getter and setter meth-
ods.
 
 
Search WWH ::




Custom Search