I am having a map of String and Object and I am getting this map from an external source, for a particular scenario, I am getting this object as
"ArrayList<LinkedHashMap<String, Double>>"
ArrayList<LinkedHashMap<String, Double>> targetDetailContainer = null;
Map<String, Object> confData = getConfData();
if (confData.containsKey("Target-Details")) {
targetDetailContainer = (ArrayList<LinkedHashMap<String, Double>>) confData
.get((Object) "Target-Details");
}
now at the last line where I am casting the Object to
"ArrayList<LinkedHashMap<String, Double>>"
I am getting a warning -
Type safety: Unchecked cast from Object to
"ArrayList<LinkedHashMap<String, Double>>"
I have tried to do type check before casting, something like this,
if (confData.containsKey("Target-Details")
&& confData.get((Object) "Target-Details") instanceof ArrayList<?>) {
targetDetailContainer = (ArrayList<LinkedHashMap<String, Double>>) confData
.get((Object) "Target-Details");
}
But it didn't worked. Please suggest something, How I can get rid of this warning.