I have the below code which casts a List object type, and I want to avoid using the @SuppressWarnings("unchecked")
annotation, but I do not want to turn it off in IDE settings as I realise the importance of it.
How would I rewrite the below so I can remove the annotation and the IDE doesnt highlight an unchecked cast warning?
I tried replacing the CaseData
with a ?
element type, but I need to state CaseData
for code later in the class.
I've looked at popular questions such as this: What is SuppressWarnings ("unchecked") in Java?
@Override
protected void buildExcelDocument(Map<String, Object> model, Workbook workbook, HttpServletRequest request,
HttpServletResponse response) throws Exception {
@SuppressWarnings("unchecked")
List<CaseData> cases = (List<CaseData>) model.get("cases");