/** Returns a list of all the issued weather forecast up to the currentTimeslot */ public List<WeatherForecast> allWeatherForecasts() { int current = timeslotRepo.currentSerialNumber(); // Some weather forecasts exist in the repo for the future // but have not been issued for the current timeslot. ArrayList<WeatherForecast> issuedReports = new ArrayList<WeatherForecast>(); for (WeatherForecast w : indexedWeatherForecasts.values()) { if (w.getTimeslotIndex() < current) { issuedReports.add(w); } } issuedReports.add(this.currentWeatherForecast()); return (List<WeatherForecast>) issuedReports; }
/** Adds a WeatherForecast to the repo */ public void add(WeatherForecast weather) { runOnce(); indexedWeatherForecasts.put(weather.getTimeslotIndex(), weather); }