In the following code, I need all the properties available in Child
class (i.e. foo, bar
). I am not interested in all other properties added by groovy.
class Parent {def foo}
class Child extends Parent {def bar}
So far none of these gets the result:
println Child.fields
println Child.properties.each{k,v->println "$k -> $v"}
println Child.declaredFields.findAll { !it.synthetic }.collect {it.name}
println Child.methods.findAll {it.name.startsWith("get")}.collect {it.name}
I am trying to find out some direct method which would give me this.
This will give you what you need:
assert ['foo', 'class', 'bar'] == B.metaClass.properties*.name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With