What is the best solution for this problem?
This is the superClass
public class Views<T> {
private T controller;
public Views() {
}
public Stage getStage(Node object){
return (Stage) object.getScene().getWindow();
}
public T getController(){
return controller;
}
public void setController(T controller){
this.controller = controller;
}
}
I have this interface:
public interface UserView extends Observer{
public void setLoginObjects(Parent root);
public void loginStartUI() throws Exception;
public void setCriarUserObjects(Parent root, User user);
public void criarUserStartUI(User user) throws Exception;
}
I have this subclass of Views:
public class UserViewImpl extends Views<UserController> implements UserView{
...
And i have this class:
public class UserController {
private UserView view;
private UserDAOImpl model;
public UserController(UserView view, UserDAOImpl model) {
this.model = model;
this.view = view;
view.setController(this);
this.model.addObserver(view);
}
...
What is the best solution for this problem?
Should i put together Views
and UserView
? (The problem for this solution is i will have more views, for example i have ParqueView
and ParqueViewImpl
, that basically will have the same methods as Views
, so there would be repeated code and i want to avoid that)
The main problem is that inside my UserController
i pass as parameter UserView
, which does not have access to super class methods, and i need to access setController
which is located in Views
class, it doesnt make sense to change the type of UserView
to Views in userController
because of the MVC