Here's John's comments...
This patch makes the following additions/changes:
*) Added these new classes:
-) MetaFieldProperty
-) MetaBeanProperty
-) PropertyValue
) Modified MetaProperty class to be the base class to above new Meta classes
*) MetaClass now gathers up all the known properties of it's representative class during
construction. This will gather up properties in the following order:
-) all public fields
-) all bean properties found via introspection
-) any public get/set methods
These properties are represented with the above-mentioned MetaProperty objects.
*) MetaClass get/setProperty() methods now first look in the MetaProperty objects collected above.
If not found in there, they look in other possible locations, like a generic get/set method,
or perhaps a protected get/set method that a superclass could define. IMHO, this logic
is still too complicated and needs more work. Groovy's design for handling properties needs
more simplification.
*) MetaClass has a new public method called getProperties(). This will return a List of
MetaProperty objects for all known properties of the class. This is the list of collected
properties from above.
*) org.codehaus.groovy.runtime.DefaultGroovyMethods has added several new methods:
-) eachPropertyName(Object self, Closure closure) This will iterate over all properties
for the given object and call the closure, passing in the property name
-) eachProperty(Object self, Closure closure) This will also iterate over all known
properties for the given object, calling the closure, passing the PropertyValue object.
With this object, the closure code can look at the property name, type, value, and even
set the value. See the PropertyValue class for details.
-) allProperties(Object self) This returns a List of PropertyValue objects for all known
properties for the given object.
What I still would like/need to do:
*) the Expando class needs to add some methods to allow his dynamic properties to be queried in
the same manner.
*) The order of searching for a property in get/setProperty() needs some tweaking. For example,
the generic get() should not be called before we check for a protected get*() method.
*) I would like to see an end to accessing a class's Class object by simply using <Classname>. This
makes some of the property code and static member access complicated. How about using ".class"?
*) I would also like to end accessing a method's reference by simply using <Methodname>.
This complicates looking up properties.
*) I would like to revamp the protocol used by the generic get(). If it returns null, getProperty()
assumes that the property was not handled and it continues looking elsewhere. This precludes
the property actually being handled by get() which has a value of null. Perhaps use an
exception to indicate that get() did not handle the property?
This looks like it fits in nicely with your scoping changes