I have the interface below
public interface BaseRelatorioDTO extends Serializable {
public BaseFiltroDTO getFiltro();
public List<? extends BaseRespostasDTO> getRespostas();
}
And I would like to create the method
public void setRespostas(final List<? extends BaseRespostasDTO> respostas);
However when creating this method, all classes that implement BaseRelatorioDTO
and already have this method begin to give the error
Name clash: The method
setRespostas(List<? extends RespostaHorariosDTO>)
of typeRelatorioHorariosDTO
has the same erasure assetRespostas(List<? extends BaseRespostasDTO>)
of typeBaseRelatorioDTO
but does not override it.
Here is an example of one of the classes:
public class RelatorioHorariosDTO implements BaseRelatorioDTO {
private static final long serialVersionUID = -3828618335258371680L;
private FiltroHorariosDTO filtro = new FiltroHorariosDTO();
private List<RespostaHorariosDTO> respostas = new ArrayList<RespostaHorariosDTO>();
@Override
public FiltroHorariosDTO getFiltro() {
return this.filtro;
}
@Override
public List<RespostaHorariosDTO> getRespostas() {
return this.respostas;
}
/**
* @param respostasParam the respostas to set
*/
public void setRespostas(final List<RespostaHorariosDTO> respostasParam) {
this.respostas = respostasParam;
}
}
If you look at my setRespostas
method, it expects as a parameter a list of RespostaHorariosDTO
, this class being written as below:
public class RespostaHorariosDTO implements BaseRespostasDTO {
private static final long serialVersionUID = 5505724855293262084L;
// Atributos e métodos acessores
}
What I am doing wrong that the method can not be declared in the interface so that I compel all classes that implement BaseRelatoriosDTO
implement the method setRespostas
?