I have a generics class, Foo
. In a method of Foo
, I want to get the class instance of type T
, but I just can\'t call T.
Actually, I suppose you have a field in your class of type T. If there's no field of type T, what's the point of having a generic Type? So, you can simply do an instanceof on that field.
In my case, I have a
Listin my class, and I check if the class type is "Locality" byitems;
if (items.get(0) instanceof Locality) ...
Of course, this only works if the total number of possible classes is limited.