How do I get the actual type of T in a generic interface?
Given the following class:
class myClazz {
private final IGenericInterface<?> genericInterface;
myClazz(final IGenericInterface<otherClazz> genericInterface){
this.genericInterface = genericInterface;
}
}
How do I get the simple name of otherClazz out of the constructor using reflection?
I tried the following:
String otherClazzString = myClazz.class.getConstructors()[0].getParameterTypes()[0].toString(); //
but I do not know what to do next to obtain the simple name of the actual type used in the generic interface.
Aucun commentaire:
Enregistrer un commentaire