Hi,
what, if at all possible, would be a good solution to implement the following desired functionality where I want to:
- Cast the return type of a routine to the type of the routine parameter, e.g.,
// Foo and Bar are two types of Common
interface Common{}
interface Foo extends Common {}
interface Bar extends Common {}
// Example interface
public List<? extends Common> getFeatureByType(Class<? extends Common> clazz);
// Example of what I want to achieve by using the (or a similar) interface.
// Can this be achieve without using typecasting to (List<Bar>) or (List<Foo>)
// and @SuppressWarning("unchecked") ?
List<Bar> bars = getFeatureByType(Bar.class);
List<Foo> foos = getFeatureByType(Foo.class);