Mam interfejs:
public interface Dao {
...
public <T> List<T> getList(List<String> idList);
public <T> List<T> getAll();
...
}
Oraz implementacje:
@Override
public List<Product> getList(List<String> idList) {
return null;
}
@Override
public List<Product> getAll() {
return null;
}
dlaczego przy impelentacji pierwszej metody występuje błąd:
Multiple markers at this line
- The method getList(List<String>) of type ProductDao must override
or implement a supertype method
- implements server.interfaces.Dao.getList
- Name clash: The method getList(List<String>) of type ProductDao
has the same erasure as getList(List<String>) of type Dao but does not override
it
a drugą mogę w taki sposób zaimplementować?
podczas gdy dopiszę do metody <Product> przed zwracanym typem
public <Product> List<Product> getList(List<String> idList) {
return new Product
.ProductBuilder("")
.setName("")
.setPrice("")
.setMadeIn("")
.setPhotoFolderPath("")
.build();
}
mogę zwrócić nulla ale nie mogę zwrocić nowego obiektu bo wyskakuje błąd
llegal qualified access from the type parameter Product
Trochę dziwne zachowanie, jo co właściwie chodzi?