Your method takes a Class<T> clazz
not an instance of LivingThing
.
Either change your method to:
public <T extends LivingThing> T getData(T livingThing, Object otherParam) {
if(livingThing instanceof Cat) {
//do something and return a new Cat
}
}
Or use the isAssignableFrom
method on Class
to test with the Class
rather than an instance:
if(Cat.class.isAssignableFrom(clazz))