I have a Collection<T>. I have a class TManager implementing an interface UManager which has a method getCollection() that needs to return a Collection<U> where U is an interface, and T is a class that implements U.
Aside from just casting it, e.g. return (Collection<U>)Tcoll;, is there a more correct way to handle this?
I control all 4 classes/interfaces here. Am I wrong in declaring UManager.getCollection as
public Collection<U> getCollection();
Should it be
public Collection<? extends U> getCollection()
?