I'm trying to implement my app with the MVP (Model-View-Presenter) pattern in Android but I'm facing a problem. I want to have an abstract base presenter with a view class property that is of a generic type ViewInterface but when creating a real presenter I'd like this property to be of the type RealPresenterView and if possible without needing to override the same function in all presenters.
As I probably didn't explain myself properly here's a bit of code to illustrate the case, first the base presenter:
abstract public class BasePresenter { protected ViewInterface view; protected ViewInterface getView() { return view; } } then the real presenter
public class RealPresenter { protected RealPresenterView view; // ... view.methodOnlyExistingInRealPresenterView(); } I wanted to be able to use the view in RealPresenter as RealPresenterView without needing to add much code in the class. Is that possible?
I've read about class templates but I haven't seen how to implement in this case without adding functions in every presenter.