Hi I am creating a code generation program, as part of it I need to extract info of the GenericType passed into a class which extends an Abstract class, for further clarification This is the class I annotated with my annotation
@MyAnnotation
public class First extends ParentC<Story, String> {
...
}
I was able to extract the element First from roundEnviornment now I need to know which classes that is provided to its super class( Story and String) I extracted super class using below snippet but I couldn't get any info on Generic type provided
TypeElement elm = //extraction of this element was successful
messager.printMessage(Diagnostic.Kind.NOTE,"==============="+ elm.asType().toString());
TypeMirror parent = elm.getSuperclass();
DeclaredType parentType = (DeclaredType)parent;
Element parentEl = parentType.asElement();
messager.printMessage(Diagnostic.Kind.NOTE,"==============="+ parentEl.asType().toString());
messager.printMessage(Diagnostic.Kind.NOTE, "==============="+ parentEl.getSimpleName());
the output of the code is given below
Note: ===============com.demo.service.First
Note: ===============com.demo.ParentC<T,K>
Note: ===============ParentC
So is there any way I can get the Type of the generic type as Story class and String class ?
Aucun commentaire:
Enregistrer un commentaire