I'm trying to implement the Command Pattern
with a generic return type in Java.
After reviewing this answer on SO I created a Command
class (interface) that looks like this:
public interface Command <T> {
T execute(ArrayList<String> list, T type);
}
public class SearchResultsPage implements Command{
@Override
public <T extends List<ProductPOJO>> T execute(ArrayList<String> list, T type) {
List<ProductPOJO> productPOJOList = generatePOJOFromSearch(list);
type.addAll(productPOJOList);
return type;
}
}
However, Eclipse keeps complaining that:
The method execute(ArrayList, T) of type SearchResultsPage must override or implement a supertype method
When I click
Create execute() in supertype Command
Eclipse automatically creates method with exact same signature I created but the error message does not go away.
How can I fix this?
Thanks!
Aucun commentaire:
Enregistrer un commentaire