@Test public void testGetLastMatchPlayed() { List<Match> matches; Match lastMatch; assertNull(MatchHelper.getLastMatchPlayed(null)); assertNull(MatchHelper.getLastMatchPlayed(new ArrayList<>())); matches = mockMatchList(10); lastMatch = MatchHelper.getLastMatchPlayed(matches); assertNull(lastMatch); markMatchesPlayed(matches, 0, 4); lastMatch = MatchHelper.getLastMatchPlayed(matches); assertEquals(lastMatch, matches.get(3)); markMatchesPlayed(matches, 6, 8); lastMatch = MatchHelper.getLastMatchPlayed(matches); assertEquals(lastMatch, matches.get(7)); markMatchesPlayed(matches, 0, 10); lastMatch = MatchHelper.getLastMatchPlayed(matches); assertEquals(lastMatch, matches.get(9)); }
public static @Nullable Match getLastMatchPlayed(List<Match> matches) { if (matches == null || matches.isEmpty()) return null; for (int i = matches.size() - 1; i >= 0; i--) { Match m = matches.get(i); if (m.hasBeenPlayed()) { return m; } } return null; }
MatchHelper { public static @Nullable Match getLastMatchPlayed(List<Match> matches) { if (matches == null || matches.isEmpty()) return null; for (int i = matches.size() - 1; i >= 0; i--) { Match m = matches.get(i); if (m.hasBeenPlayed()) { return m; } } return null; } }
MatchHelper { public static @Nullable Match getLastMatchPlayed(List<Match> matches) { if (matches == null || matches.isEmpty()) return null; for (int i = matches.size() - 1; i >= 0; i--) { Match m = matches.get(i); if (m.hasBeenPlayed()) { return m; } } return null; } private  MatchHelper(); }
MatchHelper { public static @Nullable Match getLastMatchPlayed(List<Match> matches) { if (matches == null || matches.isEmpty()) return null; for (int i = matches.size() - 1; i >= 0; i--) { Match m = matches.get(i); if (m.hasBeenPlayed()) { return m; } } return null; } private  MatchHelper(); static boolean validateMatchKey(String key); static String getEventKeyFromMatchKey(String matchKey); static @Nullable Match getNextMatchPlayed(List<Match> matches); static @Nullable Match getLastMatchPlayed(List<Match> matches); static String getMatchTitleFromMatchKey(Context context, String matchKey); static String getAbbrevMatchTitleFromMatchKey(Context context, String matchKey); }
MatchHelper { public static @Nullable Match getLastMatchPlayed(List<Match> matches) { if (matches == null || matches.isEmpty()) return null; for (int i = matches.size() - 1; i >= 0; i--) { Match m = matches.get(i); if (m.hasBeenPlayed()) { return m; } } return null; } private  MatchHelper(); static boolean validateMatchKey(String key); static String getEventKeyFromMatchKey(String matchKey); static @Nullable Match getNextMatchPlayed(List<Match> matches); static @Nullable Match getLastMatchPlayed(List<Match> matches); static String getMatchTitleFromMatchKey(Context context, String matchKey); static String getAbbrevMatchTitleFromMatchKey(Context context, String matchKey);  }