Source:
<code>public List<TriggeredNotification> evaluate(Notification notification) { List<? extends Person> subjects = NotificationCalculator.resolveGroupMembers( notification.getSubjects(), notification.getSchoolId(), manager); NotificationCalculator calculator; switch(notification.getMeasure()) { case GPA: calculator = new GpaCalc(); break; case SECTION_GRADE: calculator = new SectionGradeCalc(); break; case ASSIGNMENT_GRADE: calculator = new AssignmentGradeCalc(); break; case BEHAVIOR_SCORE: calculator = new BehaviorScoreCalc(); break; case HOMEWORK_COMPLETION: calculator = new HwCompletionCalc(); break; case SCHOOL_ABSENCE: calculator = new SchoolAbsenceCalc(); break; case SCHOOL_TARDY: calculator = new SchoolTardyCalc(); break; case SECTION_ABSENCE: calculator = new SectionAbsenceCalc(); break; case SECTION_TARDY: calculator = new SectionTardyCalc(); break; case GOAL_CREATED: calculator = new GoalCreatedCalc(); break; case GOAL_APPROVED: calculator = new GoalApprovedCalc(); break; case GOAL_MET: calculator = new GoalMetCalc(); break; case GOAL_UNMET: calculator = new GoalUnmetCalc(); break; default: LOGGER.warn("A notification with ID: " + notification.getId() + " has an an unsupported type: " + notification.getMeasure() + " and could not be evaluated for this reason"); calculator = null; break; } if (notification.getOneTime() && notification.getTriggered()) { return null; <START> } <END> if(null != calculator) { return calculator.calculate(subjects, notification, manager); } return null; }</code><technical_language>put this check big ass switch statement, because: - in case notification **isn't** one-time and/or triggered, need do check - in case notification **is** one-time triggered, need do this check, results switch statement unused entirely</technical_language>

Target:
public List<TriggeredNotification> evaluate(Notification notification) { if (notification.getOneTime() && notification.getTriggered()) { return null; } List<? extends Person> subjects = NotificationCalculator.resolveGroupMembers( notification.getSubjects(), notification.getSchoolId(), manager); NotificationCalculator calculator; switch(notification.getMeasure()) { case GPA: calculator = new GpaCalc(); break; case SECTION_GRADE: calculator = new SectionGradeCalc(); break; case ASSIGNMENT_GRADE: calculator = new AssignmentGradeCalc(); break; case BEHAVIOR_SCORE: calculator = new BehaviorScoreCalc(); break; case HOMEWORK_COMPLETION: calculator = new HwCompletionCalc(); break; case SCHOOL_ABSENCE: calculator = new SchoolAbsenceCalc(); break; case SCHOOL_TARDY: calculator = new SchoolTardyCalc(); break; case SECTION_ABSENCE: calculator = new SectionAbsenceCalc(); break; case SECTION_TARDY: calculator = new SectionTardyCalc(); break; case GOAL_CREATED: calculator = new GoalCreatedCalc(); break; case GOAL_APPROVED: calculator = new GoalApprovedCalc(); break; case GOAL_MET: calculator = new GoalMetCalc(); break; case GOAL_UNMET: calculator = new GoalUnmetCalc(); break; default: LOGGER.warn("A notification with ID: " + notification.getId() + " has an an unsupported type: " + notification.getMeasure() + " and could not be evaluated for this reason"); calculator = null; break; } if(null != calculator) { return calculator.calculate(subjects, notification, manager); } return null; }