smeeb smeeb - 6 months ago 28
Groovy Question

List Groovy constructors generated by Canonical and TupleConstructor

I have a deep hierarchy of POGOs (domain models) that make heavy use of

. I now want to list out all the dynamically-generated constructors available for any one of my domain model classes.

I found this little Groovy gem:

println MyObject.metaClass.methods*.name.sort().unique()

Which, when ran, beautifully prints a list of all the (defined and generated) methods for

But, when I try to use this for constructors:

println MyObject.metaClass.constructors*.name.sort().unique() just prints out:


How can I list out all the
- and
-generated constructors (and their respective arguments) for any given class?

More importantly (well not quite, but almost)...where is this documented?!?


Just remove metaClass:


It should show just one value: 'MyObject' (because all constructors have name MyObject)