Eclipse is giving me a warning of the following form:
Type safety: Unchecked cast from Object to HashMap
This is from a call to
Warning suppression is not a solution. You should not be doing two level casting in one statement.
HashMap getItems(javax.servlet.http.HttpSession session) {
// first, cast the returned Object to generic HashMap,?>
HashMap, ?> theHash = (HashMap, ?>)session.getAttribute("attributeKey");
// next, cast every entry of the HashMap to the required type
HashMap returingHash = new HashMap<>();
for (Entry, ?> entry : theHash.entrySet()) {
returingHash.put((String) entry.getKey(), (String) entry.getValue());
}
return returingHash;
}