/** * Finds a seasonal athlete of the given {@code type}, such as {@link BaseballAthlete}, for the * given {@code year}, and {@code team} or if not found, creates one. */ public <T extends SeasonalAthlete> T findOrCreateSeasonalAthlete( Class<T> type, int year, SeasonalTeam team) { Database database = getState().getDatabase(); T athlete = database.readFirst( Query.from(type).where("athlete = ? and year = ? and team = ?", this, year, team)); if (athlete == null) { athlete = (T) database.getEnvironment().getType(type).createObject(null); athlete.setAthlete(this); athlete.setYear(year); athlete.setTeam(team); } return athlete; }