I have a superclass with its own nested class which is passed (/injected as provider) in the constructor.
Similarly i have a subclass with its own nested class which is injected (as a provider) in the constructor. Subclass.NestedClass extends Superclass.NestedClass.
public class SuperClass {
@Inject SuperClass(Provider<SuperClass.Parameters> superParam) {
}
public class Parameters {
int a;
}
}
public class Sub extends SuperClass {
@Inject Sub(Provider<Sub.Parameters> subParam) {
// Need to call super here with the appropriate superclass's provider
}
public class Parameters extends SuperClass.Parameters {
int b;
}
}
Is there a way i can convert the Provider of Sub.Parameters to SuperClass.Parameters’s provider so that i can call super(with that provider) in the constructor of Sub.
Java generics helped me here.
Solution:
Observe the difference in the super class constructor’s parameter “? extends”.