Here is my problem:
my function in class A:
public void setData(Map<String,? extends ArrayList<? extends SomeInterface>>){...}
my call:
Map<String, ArrayList<ImplementsSomeInterface>> a=...;
instanceOfA.setData(a); //does not compile
instanceOfA.setData((Map<String,? extends ArrayList<? extends SomeInterface>>) a); // works thanks to the Casting.
I don’t think this is clean. Is there a way to avoid the casting without droping the wildcard use in the function?
First your
setDatamethod should read:Your map declaration should read:
Which is pretty much what you’ve got following your edits to the original question. The change I’ve made from
ArrayListtoListdoesn’t effect the behaviour of the code.Following comments: