7

Can somebody explain me what is POGO in groovy and is there any difference between POGO and POJO in java ?

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97

3 Answers3

9

A Groovy POGO does have different behaviour to a Java POJO, namely:

  1. Implicit getters and setters for all properties
  2. Which are public irrespective of typed access modifier
  3. They include more sophisticated metaprogramming features than Java
  4. 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