Let's assume the following class hierarchy:
class A{}
class B extends A{}
class C extends B{}
class D extends C{}
In Java, it is possible to define wildcards with generics like this:
List<? extends A> aOrDown;//A or any subtype of A
List<? super D> dOrUp;//D or any supertype of D
Is it possible to bind the same wildcard to both an upper and lower bound?
I would imagine something like this:
List<? extends A super B> combined;
List<? extends A & super B> combined;
However, those seem to raise a compile-time error.
Is there any way to do bind a generic wildcard to a specific part of the class hierarchy?
I am interested whether this is possible in theory, I don't have a practical use-case for this.