public TNextMatchesResult getMatchesToRun(
     String tournamentInternalName,
     TSeeding initialSeeding,
     List<InternalAdminAction> adminActions,
     Set<InternalMatchResult> resultsSoFar) {
   FormatRunner runner = format.getRunner();
   return runner.getMatchesToRun(
       tournamentInternalName, initialSeeding, adminActions, stageNum, rounds, resultsSoFar);
 }
 public List<TRanking> getStandingsHistory(
     String tournamentInternalName,
     TSeeding initialSeeding,
     List<InternalAdminAction> adminActions,
     Set<InternalMatchResult> resultsSoFar) {
   return format
       .getRunner()
       .getStandingsHistory(
           tournamentInternalName, initialSeeding, adminActions, stageNum, rounds, resultsSoFar);
 }
 private StageSpec(
     int stageNum,
     StageFormat format,
     ImmutableList<RoundSpec> rounds,
     int playerLimit,
     ImmutableSet<TPlayer> excludedPlayers) {
   Preconditions.checkArgument(stageNum >= 0);
   Preconditions.checkNotNull(format);
   Preconditions.checkArgument(!rounds.isEmpty());
   Preconditions.checkArgument(playerLimit > 0, "Player cutoff must be positive if present");
   format.validateRounds(rounds);
   this.stageNum = stageNum;
   this.format = format;
   this.rounds = rounds;
   this.playerLimit = playerLimit;
   this.excludedPlayers = excludedPlayers;
 }
 @SuppressWarnings("unchecked")
 public static StageSpec parseYaml(
     Object yamlStage, int stageNum, Map<String, Game> games, AtomicInteger playerLimitSoFar) {
   Map<String, Object> stageMap = (Map<String, Object>) yamlStage;
   YamlUtils.validateKeys(stageMap, "stage", ALLOWED_KEYS);
   String formatName = (String) stageMap.get("format");
   List<RoundSpec> rounds = Lists.newArrayList();
   int roundNum = 0;
   for (Object yamlRound : (List<Object>) stageMap.get("rounds")) {
     rounds.add(RoundSpec.parseYaml(yamlRound, roundNum, games));
     roundNum++;
   }
   int playerLimit = playerLimitSoFar.get();
   if (stageMap.containsKey("playerLimit")) {
     playerLimit = Math.min(playerLimit, (int) stageMap.get("playerLimit"));
     playerLimitSoFar.set(playerLimit);
   }
   if (stageMap.containsKey("playerCutoff")) {
     // This affects the player limit for the next round, not the current round.
     playerLimitSoFar.set((int) stageMap.get("playerCutoff"));
   }
   Set<TPlayer> excludedPlayers = Sets.newHashSet();
   if (stageMap.containsKey("excludedPlayers")) {
     for (Object playerName : (List<Object>) stageMap.get("excludedPlayers")) {
       // Note that playerName could actually be e.g. an Integer instead
       // of a String, so we do need toString() instead of a cast.
       excludedPlayers.add(TPlayer.create(playerName.toString()));
     }
   }
   return new StageSpec(
       stageNum,
       StageFormat.parse(formatName),
       ImmutableList.copyOf(rounds),
       playerLimit,
       ImmutableSet.copyOf(excludedPlayers));
 }