Dear XJC-Developers,
I’m writing a XJC-Plug-in (as you can easily guess) and I wonder how to access the generic information of a class. It is easy to add the generic information to a class via JClass’ narrow()-method.
For example I can create a ArrayList<String> with the followed code:
outline.getCodeModel().ref(ArrayList.class).narrow(String.class);
Assume that I have
Map<String, JFieldVar> fields = classOutline.implClass.fields();
for (JFieldVar field : cfields.values()) {
JClass fieldClass = field.type().boxify();
HOW_TO_GET_THE_TYPE_OF_THE_LIST_IN_THIS_CASE_STRING = fieldClass.getNarrowdClass(); //?
}
Is there an easy way, to get the narrowed classes? Like getNarrowedClasses() that return in the case of ArrayList<String> the String-class?
This time I need it, to create a foreach loop:
JForEach forEach = clone.body().forEach(HOW_TO_GET_THE_TYPE_OF_THE_LIST_IN_THIS_CASE_STRING, "iter", jFieldVar);
forEach.body().add(copy.ref(jFieldVar).invoke("add").arg(forEach.var()));
I hope you have a hint for me,
regards Flori