I am trying to figure out how to get generics to jump through hoops.
I have:
interface Root { }
interface Middle extends Root { }
class Type implements Root { }
And many "Subtype" classes:
class Subtype1 extends Type implements Middle { }
class Subtype2 extends Type implements Middle { }
...
What I want is to declare a class with two type parameters T and S, where T is bound by Type and S is bound by T and Middle.
I can't see a way with generics to ensure that S extends T AND implements Middle.
What I want is something like:
class Handler<T extends Root, S extends T, S extends Middle>;
or
class Handler<T extends Root, S extends <T extends Middle>>;
But of course neither are legal. Maybe there is some magic I am missing?