Hi all,
I have 5 classes that depend on each other for providing a few services and recently, I tried genericifying them and im quite happy with the result. Except that for some reason, it wont compile and I haven’t got a clue what syntax error i have made. Im sure its something to do with extends/super keywords, but im not sure:
I have this SuperInterface that most of the objects inherit from. The SuperInterfaceView is the view to the data stored inside the SuperInterface :
public interface SuperInterface {
public SuperInterfaceView<? super SuperInterface> getSuperInterfaceView();
}
public class SuperInterfaceView<T extends SuperInterface> {
public void doStuff(T stuff) {
}
}
I have another class that creates the SuperInterfaceView depending on certain characteristics outside of the data, this is called a Creator:
public abstract class Creator {
public static Creator getCreator() {
return null;
}
public abstract SuperInterfaceView<? super SuperInterface> getSuperInterfaceView( Class<? super SuperInterface> clazz );
}
A simple implementor of SuperInterface that uses the Creator is:
public class Implementor implements SuperInterface {
public SuperInterfaceView< ? super SuperInterface> getSuperInterfaceView() {
return Creator.getCreator().getSuperInterfaceView( this.getClass() );
}
}
Now the last class isn’t really needed for the above to compile without problems, but its necessary in the sense that if you get the above working, this class breaks, if you get this class fine, the Implementor breaks, they both need to be satisfied:
public class SuperInterfaceViewDistributor {
public void doStuff(SuperInterface face) {
face.getSuperInterfaceView().doStuff( face );
}
}
Eclipse complains in Implementor that:
Any ideas whats going on here?
DP