Type genericSuperclass = x.getClass().getGenericSuperclass(); if (genericSuperclass instanceof ParameterizedType) { Type[] types = ((ParameterizedType) genericSuperclass).getActualTypeArguments(); }
Then you can use Class.isAssignableFrom if type instanceof Class to check if it is Foo or not.
i.e.
if (types[0] instanceof Class) { if (x.getClass().isAssignebleFrom(((Class) type[0]))){
Bozho source share