In my abstract class, I have something like this:
public Object methodIWantToExpose(){
// ...
methodIDontWantExposed()
// ...
}
protected abstract void methodIDontWantExposed();
The thing is, I want to force the person that extends methodIDontWantExposed() to make it protected, because I don't want the extending class to have both methodIDontWantExposed and methodIWantToExpose exposed.
Is there a way to do this (or a different approach which might avoid my problem)?
No. A subclass can always make a method more public.
Even if they couldn't do this with the method you have in your class, they could always write:
public void callsMethodIDontWantExposed() {
methodIDontWantExposed();
}
... so you'd be in the same situation.
See more on this question at Stackoverflow