Is it acceptable practice to put generics on an interface when the implementation will not be generic? Lets say that my project will have many classes that read data from the database. I may make a generic interface like:
public interface DataRetriever<T, R>{
R retrieveData(T criteria);
}
public class UserDataRetriever implements DataRetriever<UserCriteria, User>{
@Override
public User retrieveData(UserCriteria criteria) {
...
}
}
Or another example might be:
public interface DataRetriever2<R>{
R retrieveData();
}
public class UserDataRetriever2 implements DataRetriever2<User>{
@Override
public User retrieveData() {
...
}
}
With having generics on interfaces, it looks like I can get way more re-usability out of my interfaces and don't need one interface per data retrieval class. However, I have concerns that the documentation for my interface is forced to be vague. People also have to adhere to the number of parameters on the retrieveData method so they might be creating a new pojo object for scenario 1 or might be forced to put everything in the constructor in scenario 2. Thoughts on using generics here when the implementation will not use generics?