I know that i can get parameterized types of a class in the following way:
Type[] genericInterfaces = getClass().getGenericInterfaces();
for (Type genericInterface : genericInterfaces) {
if (genericInterface instanceof ParameterizedType) {
ParameterizedType type = (ParameterizedType) genericInterface;
// do something
}
}
But suppose i need to check for a specific parameterized type, like List<T>
. The type
offers getRawType().getTypeName()
and i could compare that to the class name (or simple class name, i am not sure) of List
. Is this the right way to go?
Aucun commentaire:
Enregistrer un commentaire