public void serialize(File file) throws FileNotFoundException {
   FileOutputStream fos = new FileOutputStream(file);
   PrintWriter printWriter = new PrintWriter(fos);
   List items = new ArrayList(runEntryStatistics.values());
   Collections.sort(items, new RunCountComparator());
   RunEntryStatistics item;
   for (Iterator iter = items.iterator(); iter.hasNext(); ) {
     item = (RunEntryStatistics) iter.next();
     printWriter.println(item.getAsString());
   }
   printWriter.close();
 }
 static RunEntryStatisticsMap fromReader(Reader fileReader) throws IOException {
   Map result = new HashMap();
   BufferedReader bufferedReader = new BufferedReader(fileReader);
   String line = bufferedReader.readLine();
   while (line != null) {
     if (!line.startsWith("#")) {
       final RunEntryStatistics stats = RunEntryStatistics.fromString(line);
       result.put(stats.getTestName(), stats);
     }
     line = bufferedReader.readLine();
   }
   return new RunEntryStatisticsMap(result);
 }
 public int compare(Object o, Object o1) {
   RunEntryStatistics re = (RunEntryStatistics) o;
   RunEntryStatistics re1 = (RunEntryStatistics) o1;
   int runtime = re.getSuccessfulBuilds() - re1.getSuccessfulBuilds();
   if (runtime == 0) {
     return re.getRunTime() - re1.getRunTime();
   }
   return runtime;
 }
 public RunEntryStatistics createNextGeneration(ReportEntry reportEntry) {
   final RunEntryStatistics newItem = findOrCreate(reportEntry);
   final Integer elapsed = reportEntry.getElapsed();
   return newItem.nextGeneration(elapsed != null ? elapsed.intValue() : 0);
 }
 public RunEntryStatistics findOrCreate(ReportEntry reportEntry) {
   final RunEntryStatistics item =
       (RunEntryStatistics) runEntryStatistics.get(reportEntry.getName());
   return item != null ? item : RunEntryStatistics.fromReportEntry(reportEntry);
 }
 public void add(RunEntryStatistics item) {
   runEntryStatistics.put(item.getTestName(), item);
 }