Please review and recommend improvements. It looks horrible to me, difficult to read, too lengthy, and just plain old inelegant. But I don't see the potential improvements.
private boolean useCachedReportBean(BeanReport cachedReportBean, String strRequestedReportID)
throws ExceptionInvalidReportRequest
{
/* There may or may not be a cached report
* bean, and their may or may not be a requested
* report ID. If both exist, and they match, use
* the cached report bean. If only one of
* the two exist, use it. Finally if neither exist,
* throw an Exception.
*/
if (strRequestedReportID == null || "".equals(strRequestedReportID)) {
if (cachedReportBean == null) {
throw new ExceptionInvalidReportRequest(
"The request ID is invalid and no cached report exists.");
} else {
/* There was no requested ID but there is a cached bean.
* Returning true causes the cache to be used. */
return true;
}
}
/* If we are here, we know that there is a requested ID.
* If there is no cached bean, use the request id. */
if (cachedReportBean == null) {
return false;
}
/* There is a requested ID and cached bean. If they match, use the cached bean. */
if (strRequestedReportID.equalsIgnoreCase(cachedReportBean.getConfigBean().getReportID())) {
return true;
} else {
return false;
}
}
throw
in anif
, there is no need for anelse
\$\endgroup\$