Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OpenWeather REST and file connector
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SOFT Core
SOFT 160
OpenWeather REST and file connector
Commits
54daeaac
Commit
54daeaac
authored
1 year ago
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
NPE no longer thrown when requesting data for a timestamp not in the list
NoSuchElementException is thrown instead. Closes
#1
parent
a1690583
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/edu/unl/cse/soft160/json_connections/connector/OpenWeatherConnector.java
+7
-3
7 additions, 3 deletions
...t160/json_connections/connector/OpenWeatherConnector.java
with
7 additions
and
3 deletions
src/main/java/edu/unl/cse/soft160/json_connections/connector/OpenWeatherConnector.java
+
7
−
3
View file @
54daeaac
...
...
@@ -12,6 +12,7 @@ import java.io.IOException;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.NoSuchElementException
;
import
java.util.Set
;
/**
...
...
@@ -372,10 +373,10 @@ public class OpenWeatherConnector {
*
* @param listName the key to access the list
* @param timestamp the timestamp of the list entry
* @return the object of interest, or null if the list
or the timestamp are no
t
*
presen
t
* @return the object of interest, or null if the list
is not presen
t
*
@throws NoSuchElementException if the timestamp is not present in the lis
t
*/
private
JSONObject
getListEntry
(
String
listName
,
Date
timestamp
)
{
private
JSONObject
getListEntry
(
String
listName
,
Date
timestamp
)
throws
NoSuchElementException
{
JSONObject
listEntry
=
null
;
if
(
data
.
containsKey
(
listName
))
{
JSONArray
list
=
(
JSONArray
)
data
.
get
(
listName
);
...
...
@@ -384,6 +385,9 @@ public class OpenWeatherConnector {
listEntry
=
(
JSONObject
)
entry
;
}
}
if
(
listEntry
==
null
)
{
throw
new
NoSuchElementException
(
"The requested data is not available for "
+
timestamp
+
"."
);
}
}
return
listEntry
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment