It's probably a simple question but I dont see it.
I have an interface
public interface RenderableListener<T extends Renderable>{
public void update(T element);
}
I have a super class Renderable and a example class Foo that is extending Renderable.
now, when creating class Foo I give an instance of the interface as listener/ observer or whatever.
Foo foo = new Foo(new RenderableListener<Foo>(){
public void update(Foo element){}
});
so far everything works and is as it should be.
but now in the Foo class itself when I try to call the interface like this:
public class Foo extends Renderable {
private final RenderableListener<? extends Renderable> listener;
public Foo(RenderableListener<? extends Renderable> listener){
this.listener = listener;
}
public void update(){
listener.update(this);
}
}
I get this error:
Now the issue I have is that SpriteRenderable, the argument in question is extending Renderable. What am I missing?
edit: the idea behind this is that I can use one interface implementation for every class extending Renderable (and there will be plenty).