I wrote this interface as part of the framework.
public interface CollectionFactory { public <T> Collection<T> newCollection(); }
But I want the developer to be able to determine the return type of the collection, so they should not be selected as:
public interface CollectionFactory<C extends Collection> { public C newCollection(); }
The problem is that I then lose types on T. I would like her to be
public interface CollectionFactory<C extends Collection> { public <T> C<T> newCollection(); }
And I do not want to specify T in advance like this:
public interface CollectionFactory<T, C extends Collection<T>> { public C newCollection(); }
As far as I know, this is not possible.
Would anyone like to surprise me?
Also, like the appetizer, does anyone know if something like this is possible in ... Scala ?
source share