Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • jkenney6/openweather-rest-and-file-connector
  • gswartz2/openweather-rest-and-file-connector
  • egueret2/openweather-rest-and-file-connector
  • zalexander2/openweather-rest-and-file-connector
  • rlanning2/openweather-rest-and-file-connector
  • soft-core/soft-160/openweather-rest-and-file-connector
6 results
Select Git revision
Show changes
Commits on Source (2)
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
- [*"weather"*](https://openweathermap.org/current), the current weather - [*"weather"*](https://openweathermap.org/current), the current weather
data set data set
- [*"onecall"*](https://openweathermap.org/api/one-call-api), the "One - [*"onecall"*](https://openweathermap.org/api/one-call-api), the "One
Call API" data set Call v2.5 API" data set (note: does *not* use the v3.0 API)
- [*forecast*](https://openweathermap.org/forecast5), the 5-day/3-hour - [*forecast*](https://openweathermap.org/forecast5), the 5-day/3-hour
forecast data set forecast data set
- [*air_pollution*](https://openweathermap.org/api/air-pollution), the air - [*air_pollution*](https://openweathermap.org/api/air-pollution), the air
......
...@@ -12,6 +12,7 @@ import java.io.IOException; ...@@ -12,6 +12,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set; import java.util.Set;
/** /**
...@@ -372,10 +373,10 @@ public class OpenWeatherConnector { ...@@ -372,10 +373,10 @@ public class OpenWeatherConnector {
* *
* @param listName the key to access the list * @param listName the key to access the list
* @param timestamp the timestamp of the list entry * @param timestamp the timestamp of the list entry
* @return the object of interest, or null if the list or the timestamp are not * @return the object of interest, or null if the list is not present
* present * @throws NoSuchElementException if the timestamp is not present in the list
*/ */
private JSONObject getListEntry(String listName, Date timestamp) { private JSONObject getListEntry(String listName, Date timestamp) throws NoSuchElementException {
JSONObject listEntry = null; JSONObject listEntry = null;
if (data.containsKey(listName)) { if (data.containsKey(listName)) {
JSONArray list = (JSONArray) data.get(listName); JSONArray list = (JSONArray) data.get(listName);
...@@ -384,6 +385,9 @@ public class OpenWeatherConnector { ...@@ -384,6 +385,9 @@ public class OpenWeatherConnector {
listEntry = (JSONObject) entry; listEntry = (JSONObject) entry;
} }
} }
if (listEntry == null) {
throw new NoSuchElementException("The requested data is not available for " + timestamp + ".");
}
} }
return listEntry; return listEntry;
} }
......