How to hide metaClass property in Groovy class

I create some simple groovy classes, for example.

class Person {
    int age
    String name
}

which are used in a Java method that relies on reflection to pull out the properties of an object, for example. age and name. The problem is that metaClass is also displayed as a property. Updating the Java method to ignore this property is not an option. I tried to set the metaClass property to null, but that did not work.

+3
source share
2 answers

If you use these classes from Java and Groovy, why not just create a POJO in Java, not Groovy. I know this does not answer your question, but it would be nice to know why the decision to use Groovy for POJO

+1

MetaClass Groovy . , , Null. setMetaClass, , , , , Null, , .

0

Source: https://habr.com/ru/post/1707698/


All Articles