Re: [Jython-users] Auto getter/setter generation?
by Diez B. Roggisch other posts by this author
Dec 4 2004 5:35PM messages near this date
[Jython-users] Auto getter/setter generation?
|
[Jython-users] GUI for Jython app
Am Samstag, 4. Dezember 2004 07:10 schrieb Owen Densmore:
> I'm using Jython within a Java framework which uses bean
> getter/setters. Thus when I build a class in Jython to be used by this
> framework, I need to build getter/setter methods in the Jython class.
>
> My question is: is there a way to have Jython auto-generate these?
> Groovy, for example, intercepts getter/setters from Java and
> automatically converts them to property/attribute requests. I presume
> because Jython has foo.var abbreviations, it might somehow do a similar
> thing, removing the need for the annoying getter/setter hand-made code.
Certainly not - in jython you can do:
class Foo():
def __init__(self):
if relative_moon_moisture > 0.3:
self.__dict__[generate_property_name()] = "jikes"
This is totally runtime dependand, and can't be foreseen. So there is no way
the compiler could introduce compile-time methods for that.
Maybe the compiler could add some magic if a __slots__ property is used - but
as these are new-style class features, its only to happen in upcoming
versions.
Diez
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Jython-users mailing list
Jython-users@[...].net
https://lists.sourceforge.net/lists/listinfo/jython-users
Thread:
Owen Densmore
Diez B. Roggisch
|