In:
// services
public interface Mother { public Collection<? extends Father> getMamaStuff() {}}
public interface Daughter extends Mother {}
// data
public interface Father { public String getPapaStuff() }
public interface Son extends Father { public String playLoudMusic() }
why is this not allowed:
public class Clazz {
Clazz(Daughter daughter) {//boilerplate}
public Collection<Son> idk = doughter.getMamaStuff();
}
- Is it because there is no way to know which implementation of Father will Clazz get?
- What is the good way to work around this?
- Is instanceof good practice in this case?
It seems to me there is no way around type checking.