I am trying to parameter a class with a type that is whether A or B and nothing else.
Something like
final class ChildClass<A | B> extends MotherClass {
This way I can create a ChildClass<A> or a ChildClass<B> but nothing else.
Is it possible in Java?
Edit:
I must specify that I am using Java 8 and that I have no control of classes A and B (which are classes of the Android framework I am working with).