You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by mg <mg...@arscreat.com> on 2017/12/12 11:15:43 UTC

Retrieving Property Annotations

Hi,
I need to retrieve annotations on auto-generated properties, including for fields coming from traits.
Afaics the annotations I am looking for only live on the properties' backing fields. 
MetaBeanProperty#getField() returns null for all properties not defined in the class the MetaBeanProperty|s were retrieved for using foo.metaClass.properties. For properties coming from super classes this can be circumvented by retrieving the properties for each parent class, but this does not work for traits. CachedClass#getFields() does include the backing fields coming from traits, but the name is prefixed with the canonical trait class name, so it cannot be matched directly, so I would need to subtract the trait prefix... yuk
So before I go down this inelegant route (which might break in the future), I wanted to ask if anyone has a better suggestion ?
Thanks,mg