Skip to content

Commit

Permalink
[Weather] Add a default of 240 minutes for the updateInterval. (openh…
Browse files Browse the repository at this point in the history
…ab#4403)

* Add a default of 240 minutes for the updateInterval.

Also added an early shortcut in the validation logic.

* Fix formatting.

* Update to include a constant for the default update interval.
  • Loading branch information
9037568 authored and watou committed May 25, 2016
1 parent b23014c commit c05b23e
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
* @since 1.6.0
*/
public class LocationConfig {
private static final int DEFAULT_UPDATE_INTERVAL = 240;

private ProviderName providerName;
private String language = "en";
private Double latitude;
private Double longitude;
private String woeid;
private Integer updateInterval;
private Integer updateInterval = DEFAULT_UPDATE_INTERVAL;
private String locationId;
private String name;

Expand Down Expand Up @@ -145,12 +147,15 @@ public void setName(String name) {
*/
public boolean isValid() {
boolean valid = providerName != null && language != null && updateInterval != null && locationId != null;
if (!valid) {
return false;
}

if (providerName == ProviderName.YAHOO) {
valid = valid && woeid != null;
return woeid != null;
} else {
valid = valid && latitude != null && longitude != null;
return latitude != null && longitude != null;
}
return valid;
}

/**
Expand Down

0 comments on commit c05b23e

Please sign in to comment.