/** First creates a record for each of the matches in this round before creating the round. */ @Override public ContentValues toContentValues(LeagueRound round, ElifutPersistenceService service) { return ContentValuesBuilder.create() .put("round_number", round.roundNumber()) .put("matches", TextUtils.join(",", Lists.transform(round.matches(), service::create))) .build(); }
@Override public LeagueRound fromCursor(SimpleCursor cursor, ElifutPersistenceService service) { List<Integer> matchIds = Lists.transform(Arrays.asList(cursor.getString("matches").split(",")), Integer::valueOf); List<? extends Match> matches = service.query(AutoValueClasses.MATCH, Ints.toArray(matchIds)); return LeagueRound.create( cursor.getInt("id"), cursor.getInt("round_number"), listSupertype(matches)); }