Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.5.7
-
None
-
None
-
Patch
Description
It doesn't seem possible to do something like this:
class Company {
String name
Employee md
Employee cio
}
class Employee {
String name
}
def builder = new ObjectGraphBuilder()
def company = builder.company( name: 'ACME' )
{ md( name: 'Billy Bob') cio( name: 'Joey Johns') }}
Where the same class is associated mutliple times by different fields.
Why not use the field name as the builder nodes and have ObjectGraphBuilder determine the class using reflection?
I have attached a patch that does this. Unfortunately I had trouble building groovy-core so I wasn't able to run the ObjectGraphBuilder or add extra tests.
Anyway, I just wanted to see if anyone thought this was a good idea, then maybe I can finish it off.
This patch slightly changes the meaning of the classNameResolver - it would only apply to "root" classes. Maybe it should be renamed and the docs updated.