I'm looking for assistance on how to implement this Repository. Here's what I have so far:
public interface IEntity {
int getId(); //would rather not depend on int. fix later.
}
public interface IRepository<T extends IEntity> {
Collection<T> findAll();
T find(T t);
T findById(int id); //would rather not depend on int. fix later.
void add(T t);
void remove(T t);
}
public interface ISurveyRepository extends IRepository<Survey> {
}
The problem I'm running into is that I need for T in the IRepository signature to extend IEntity, but I don't need IRepository in the ISurveyRepository signature to have a bounded type parameter. I would like for the signature to just be
public interface ISurveyRepository extends IRepository { }
so that I could create a concrete class that just implements ISurveyRepository
public class MySurveyRepository extends ISurveyRepository { }
How can I go about doing that?
IRepositorywith the type parameter? Note that you don't implement an interface byextends, but byimplements.IRepositoryextendIEntity?Surveyshould implementIEntity.