0

For example, we have the next classes

class AAA {
    String fieldA
}

class BBB {
    AAA aaa
}

And now, after I run the:

GrailsClassUtils.getPropertyType(BBB.class, "aaa")

I've got an "AAA" as the result. But if code will look as:

class BBB {
    static hasMany = [aaa: AAA]
}

I've got an "java.util.Set" as the result. It is correct, but what I must to do if I need the result as "java.util.Set<AAA>" or better as "AAA"?

Actually I must ask "BBB" is the "aaa.fieldA" legal construction if "aaa" is "Set" or another "Collection" (List, Map, ...).

wwarlock
  • 443
  • 4
  • 14

1 Answers1

2

You should be able to do:

Class type = BBB.hasMany.aaa

As hasMany is just a static Map. To get back the generic type of a Collection you could try something like this.

Community
  • 1
  • 1
tim_yates
  • 167,322
  • 27
  • 342
  • 338