You can't do what you're trying to do.
Since T is a subclass of Model:
- every T is a Model
- but not every Model is a T.
Specifically:
If you construct a new Model by calling new Model(), the instance is exactly a Model and not an instance of any subclass.
Where Subclass extends Superclass, you can never successfully do this:
(Subclass) new Superclass();
Because of this, you can not successfully cast a new Model to an instance of T.
The compiler will just give you a warning which you can either ignore or suppress, but you'll get a ClassCastException when you run your program and call the add() method.