Unfortunately there is no way to have protected methods in an interface. All methods in an interface are implicitly public
and abstract
. Any attempt to deviate from that pattern will not compile.
The following three methods are implicitly identical despite their appearance.
public abstract void doSomething();
public void doSomething();
void doSomething();
If however, you declare anything that explicitly contradicts the above, it will not compile. For example;
protected abstract void doSomething(); // Does not compile
public final void doSomething(); // Does not compile
A simple solution might be to make an abstract class fit the bill somehow. You could try having AbstractMovableObject
and your new AbstractRenderableObject
class both extend a third class that had this protected update()
method (eg AbstractUpdatableObject
)? That way they would both BE-A AbstractUpdatableObject
, but would otherwise have a very limited relationship (no more than they would if they implemented the same interface) and could even have different implementations of update();
.