creating proxy object in groovy
- by IttayD
Hi,
I am looking for how to write a method that accepts some value and returns a proxy to that value where the underlying value can be retrieved with an accessor:
def p = toProxy(1)
assert p == 1
assert p * 2 == 2
assert p.underlying == 1
def p2 = toProxy(objWithMethodFoo)
p2.foo()
p2.underlying.foo()
I want to do this per object instance (not for all objects of some class) and without the need to use special 'use' constructs.