Groovy will not add accessors if a member is declared with an access modifier: private, secure, or public. If you donβt need accessors, just add a suitable modifier. Here is an example that illustrates this:
class Test1 { private int blat } println Test1.metaClass.getMethods()*.name.findAll { it.endsWith("Blat") } class Test2 { protected int blat } println Test2.metaClass.getMethods()*.name.findAll { it.endsWith("Blat") } class Test3 { public int blat } println Test3.metaClass.getMethods()*.name.findAll { it.endsWith("Blat") } class Test4 { int blat } println Test4.metaClass.getMethods()*.name.findAll { it.endsWith("Blat") }
Print
[] [] [] [getBlat, setBlat]
ataylor
source share