The closest question I found (Method Chaining: How to use getThis() trick in case of multi level inheritance) did not have a direct answer to my problem. I'm currently using morphia and am setting up a rest service. I've seen many versions of how to implement this and decided to do it this way. I am completely open to suggestions however, learning how to get through this problem, will help my coding practices, at least I think it will. Also, I know my naming conventions may be off so a correction in that I am open to as well :)
Here's my code:
1st
/*****************************************************************************/
public interface BaseRepository <T extends BaseEntity> {
/* Methods Here */
}
public class BaseController<T extends BaseEntity> implements BaseRepository<T> {
public BaseController(Class<T> type) {
this.type = type;
}
/* Overridden Methods Here*/
}
2nd
/*****************************************************************************/
public interface UserRepository<T extends UserEntity> extends BaseRepository<UserEntity> {
/* Methods Here */
}
public class UserController<T extends UserEntity> extends BaseController<UserEntity> implements UserRepository<T> {
Class<T> type;
public UserController(Class<T> type) {
super(type); // <---- Error Here
this.type = type;
}
Eventually, I will want to have a StudentController, StaffController, etc. inherit from UserController. And BaseController will be the parent to other Controllers (not users). However, I did not know the proper way to go about this. I did try to satisfy
public UserController(Class<T> type) {
super(type); // <---- Error Here
this.type = type;
}
replacing "type" in super(type) with UserEntity.class, however that would only allow the Basecontroller to return UserEntity properties. Any solutions? If there is a way...Like I said, I'm still learning and am completely open to other suggestions in approaching this issue or any advice in this particular problem. Much appreciated! Thanks :)