Java generics converting Future of list of concrete class to future of
list of interface?
I'm trying to convert a Future of List of Concrete classes into a future
of List of Interfaces, but I get an "incompatible types" error when I try
it. Basically my code looks something like this
public void main()
{
Future<List<ConcreteClass>> future = getFutureStuff();
doStuffWithInferface(future); // Syntax Error!
}
public void doStuffWithInterface(Future<List<InterfaceClass>>)
{
blah();
}
Is there a good way to change this without changing the getFutureStuff
signature to
public Future<? extends List<? extends InterfaceClass>> getFutureStuff();
and littering my code with ? extends InterfaceClass.
No comments:
Post a Comment