In Java, what is the “right” way to implement an interface where the parameters for a method require parametric polymorphism?
For example, my interface contains:
public int addItem(Object dto);
The interface is implemented by different classes, but each dto parameter is one of various strongly typed objects, such as planeDTO, trainDTO or carDTO.
For example, in my planeDAO class:
public int addItem(planeDTO dto) { ... }
Is it possible to simply implement with the dto parameter as Object, and then apply to the corresponding type?
source
share