public boolean isTeamScoredNGoalsInPeriod(TeamLocation teamLocation, int period, Double total) { if (teamLocation == TeamLocation.ANY) { throw new RuntimeException("lol"); } Period periodByNumber = getPeriodByNumber(period); int homeTotal = periodByNumber.getHomeTotal(); int guestTotal = periodByNumber.getGuestTotal(); int teamTotalInPeriod; if (teamLocation == TeamLocation.HOME) { teamTotalInPeriod = homeTotal; } else if (teamLocation == TeamLocation.GUEST) { teamTotalInPeriod = guestTotal; } else if (match.getFavoriteInfo().getFavorite() == Favorite.NONE) { throw new RuntimeException("lol"); } else if (teamLocation == TeamLocation.FAVORITE) { teamTotalInPeriod = isFavoriteHome() ? homeTotal : guestTotal; } else if (teamLocation == TeamLocation.NOTFAVORITE) { teamTotalInPeriod = isFavoriteHome() ? guestTotal : homeTotal; } else { throw new RuntimeException("lol"); } return teamTotalInPeriod >= total; }