我有以下HashMap,它返回Studentlist,Booklist和Subjectlist。
Map<String, Object> resultMap = new HashMap<String, Object>();
ResultSet rs1 = (ResultSet) storedProcedureCall.getObject(4);
ResultSet rs2 = (ResultSet) storedProcedureCall.getObject(5);
ResultSet rs3 = (ResultSet) storedProcedureCall.getObject(6);
List<Object> studIds = getStudentIds("studentID", rs1);
List<book> bookList = getBookList("books", rs2);
List<book> bookSubjects = getBookSubjects("subjects", rs3);
resultMap.put("studList", studIds);
resultMap.put("bookList", bookList);
resultMap.put("subjList", bookSubjects);
if (resultMap.isEmpty()) {
return Optional.empty();
} else {
return Optional.of(resultMap);
}
如何处理studlist,booklist,subjlist的空值。目前我依赖于isEmpty()但是当空值出现时仍然会得到NullpointerException。由于我无法在java中找到isNull(),我该如何处理这个异常。