my problem is the following:
I have an executor that runs some long running task on an Arraylist of custom Objects. I want to able to feed the executor Arraylists of different class types each of which implements an interface so that the executor knows what to do with any compatible class instance.
class MyExectorService{
....
interface MyInterface{
String getData();
}
}
class A implements MyExecutor.MyInterface {} ....
class B implements MyExecutor.MyInterface {} ....
my executer singleton has a method signature:
public void submitList(ArrayList<MyInterface> list, ....)
When I have an ArrayList of class A, or B, etc. I get a wrong parameter type exception from the compiler. I can create some function that just returns a raw type of ArrayList to convert it before submitting it
e.g.
public static ArrayList getRaw(ArrayList list){
return list;
}
...MyExecutorService.getInstance().submitList(getRaw(aa /* arraylist of class A /*),...)
but what is the correct way to do this please?