I have a feeling that this if/else should be refactored out but I’m unsure of what I can do, or whether I should just let it be as it is…
private String someReportUrl(HttpServletRequest request, HttpServletResponse response) {
String url;
if (isBackToReportsSummary(request)) {
url = SUMMARY_PAGE;
getReportsSummary(request, response);
} else if (isComingFromPageA(request)) {
url = getTabUrl(request, REPORT_URL_FOR_PAGE_A);
}
else {
url = "/standAlone/reportUrl.jsp";
}
return url;
}
Basically I have a reports summary page which lists three to four reports. First if condition is when the user wants to go back to that page, second condition is for when user has selected this particular report, and the third condition is for when the user selects this report as a stand alone report (not from summary page).
If you absolutely want to change it, you could initialise
urlto the default return and only change it if one of the two conditions is met:But really, it’s fine as is.