Can somebody explain me what is POGO in groovy and is there any difference between POGO and POJO in java ?
Asked
Active
Viewed 2,927 times
7
-
1First google result of groovy+POGO: https://www.accelebrate.com/blog/call-pogo-name/ – jalopaba Sep 19 '16 at 11:01
3 Answers
9
A Groovy POGO does have different behaviour to a Java POJO, namely:
- Implicit getters and setters for all properties
- Which are public irrespective of typed access modifier
- They include more sophisticated metaprogramming features than Java
- And named map based default constructors

William Greenly
- 3,914
- 20
- 18
-
#4 applies the same to both Java and Groovy classes. The map based constructor stuff is imposed at the calling end, not in the class being instantiated. – Jeff Scott Brown Sep 19 '16 at 18:43
-
1#2 seems to suggest that if you do something like `protected someProperty` or `private someProperty` that the field will be public, which is not true. The field will be `protected` or `private` as specified. What makes it look as if it is public is Groovy allows you to access those members directly from any Groovy class, but they are still `protected` or `private`. Inspect the generated byte code to verify that. That distinction is important because `private` field defined in a Groovy class still cannot be accessed directly from Java without using `setAccessible`. – Jeff Scott Brown Sep 19 '16 at 18:45
1
It's just a Plain Old Groovy Object. Same basic idea. You can use them interchangeably.

chrylis -cautiouslyoptimistic-
- 75,269
- 21
- 115
- 152
1
POGO:- Plain Old Groovy Object, in groovy it is named as POGO, else it is same as POJO:- Plain Old Java Object. both are same.

yash
- 2,101
- 2
- 23
- 32