reflection - Groovy: how to get properties declared in base class -
in following code, need properties available in child
class (i.e. foo, bar
). not interested in other properties added groovy.
class parent {def foo} class child extends parent {def bar}
so far none of these gets 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 trying find out direct method give me this.
this give need:
assert ['foo', 'class', 'bar'] == b.metaclass.properties*.name
Comments
Post a Comment