groovy define metaclass with its own custom methods and set it for the object -
is possible set metaclass
object in groovy
custom methods? mean kind of dynamic inheritance...
for example this
class original { def my_method() { } } class meta { def meta_method() { } } def obj = new original() obj.metaclass = new meta() obj.meta_method()
you can use traits achieve kind of things. it's little more "high level" directly manipuling metaclass
class original { def my_method() { } } trait meta { def meta_method() { } } def obj = new original().withtraits meta obj.meta_method()
Comments
Post a Comment