diff --git a/src/main/java/net/aksingh/owmjapis/CurrentWeather.java b/src/main/java/net/aksingh/owmjapis/CurrentWeather.java
index 09478f8..989c036 100644
--- a/src/main/java/net/aksingh/owmjapis/CurrentWeather.java
+++ b/src/main/java/net/aksingh/owmjapis/CurrentWeather.java
@@ -53,6 +53,7 @@ public class CurrentWeather extends AbstractWeather {
JSON Keys
*/
private static final String JSON_RAIN = "rain";
+ private static final String JSON_SNOW = "snow";
private static final String JSON_SYS = "sys";
private static final String JSON_BASE = "base";
private static final String JSON_CITY_ID = "id";
@@ -69,6 +70,7 @@ public class CurrentWeather extends AbstractWeather {
private final Coord coord;
private final Main main;
private final Rain rain;
+ private final Snow snow;
private final Sys sys;
private final Wind wind;
@@ -94,6 +96,9 @@ public class CurrentWeather extends AbstractWeather {
JSONObject rainObj = (jsonObj != null) ? jsonObj.optJSONObject(JSON_RAIN) : null;
this.rain = (rainObj != null) ? new Rain(rainObj) : null;
+ JSONObject snowObj = (jsonObj != null) ? jsonObj.optJSONObject(JSON_SNOW) : null;
+ this.snow = (snowObj != null) ? new Snow(rainObj) : null;
+
JSONObject sysObj = (jsonObj != null) ? jsonObj.optJSONObject(JSON_SYS) : null;
this.sys = (sysObj != null) ? new Sys(sysObj) : null;
@@ -150,6 +155,13 @@ public class CurrentWeather extends AbstractWeather {
return (rain != null);
}
+ /**
+ * @return true
if Snow instance is available, otherwise false
.
+ */
+ public boolean hasSnowInstance() {
+ return (snow != null);
+ }
+
/**
* @return true
if Sys instance is available, otherwise false
.
*/
@@ -213,6 +225,13 @@ public class CurrentWeather extends AbstractWeather {
return this.rain;
}
+ /**
+ * @return Snow instance if available, otherwise null
.
+ */
+ public Snow getSnowInstance() {
+ return this.snow;
+ }
+
/**
* @return Sys instance if available, otherwise null
.
*/
@@ -363,6 +382,49 @@ public class CurrentWeather extends AbstractWeather {
}
}
+ /**
+ *
+ * Parses snow data and provides methods to get/access the same information.
+ * This class provides has
and get
methods to access the information.
+ *
+ * has
methods can be used to check if the data exists, i.e., if the data was available
+ * (successfully downloaded) and was parsed correctly.
+ * get
methods can be used to access the data, if the data exists, otherwise get
+ * methods will give value as per following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
* Parses sys data and provides methods to get/access the same information.