diff --git a/build.gradle b/build.gradle
index a8b052e..e1fbe15 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,7 +6,7 @@ sourceCompatibility = 1.5
group = 'net.aksingh'
archivesBaseName = "owm-japis"
-version = '2.5.0.4'
+version = '2.5.0.5'
repositories {
mavenCentral()
@@ -77,4 +77,4 @@ uploadArchives {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index a77688b..2ab0c56 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,3 +1,25 @@
+#
+# Copyright (c) 2013-2015 Ashutosh Kumar Singh true
if Coord instance is available, otherwise false
.
*/
public boolean hasCoordInstance() {
- return (coord != null);
+ return coord != null;
}
public long getCityCode() {
diff --git a/src/main/java/net/aksingh/owmjapis/AbstractResponse.java b/src/main/java/net/aksingh/owmjapis/AbstractResponse.java
index 80d7764..f0bb35d 100644
--- a/src/main/java/net/aksingh/owmjapis/AbstractResponse.java
+++ b/src/main/java/net/aksingh/owmjapis/AbstractResponse.java
@@ -36,6 +36,11 @@ import java.io.Serializable;
* @since 2.5.0.3
*/
abstract class AbstractResponse implements Serializable {
+ /*
+ JSON Keys
+ */
+ private static final String JSON_RESPONSE_CODE = "cod";
+
/*
Instance variables
*/
@@ -51,8 +56,6 @@ abstract class AbstractResponse implements Serializable {
}
AbstractResponse(JSONObject jsonObj) {
- final String JSON_RESPONSE_CODE = "cod";
-
this.rawResponse = (jsonObj != null) ? jsonObj.toString() : null;
this.responseCode = (jsonObj != null) ? jsonObj.optInt(JSON_RESPONSE_CODE, Integer.MIN_VALUE) : Integer.MIN_VALUE;
}
@@ -61,21 +64,21 @@ abstract class AbstractResponse implements Serializable {
* @return true
if response is valid (downloaded and parsed correctly), otherwise false
.
*/
public boolean isValid() {
- return (this.responseCode == 200);
+ return this.responseCode == 200;
}
/**
* @return true
if response code is available, otherwise false
.
*/
public boolean hasResponseCode() {
- return (this.responseCode != Integer.MIN_VALUE);
+ return this.responseCode != Integer.MIN_VALUE;
}
/**
* @return true
if raw response is available, otherwise false
.
*/
public boolean hasRawResponse() {
- return (this.rawResponse != null);
+ return this.rawResponse != null;
}
/**
diff --git a/src/main/java/net/aksingh/owmjapis/AbstractWeather.java b/src/main/java/net/aksingh/owmjapis/AbstractWeather.java
index ee9f497..e9b18fd 100644
--- a/src/main/java/net/aksingh/owmjapis/AbstractWeather.java
+++ b/src/main/java/net/aksingh/owmjapis/AbstractWeather.java
@@ -77,13 +77,6 @@ public abstract class AbstractWeather extends AbstractResponse {
long sec = (jsonObj != null) ? jsonObj.optLong(JSON_DATE_TIME, Long.MIN_VALUE) : Long.MIN_VALUE;
if (sec != Long.MIN_VALUE) { // converting seconds to Date object
- /*
- Bugfix: It always return "Sat Jan 17 04:10:42 CET 1970"
- Issue: #3 at http://code.aksingh.net/owm-japis/issue/3/problem-with-datetime
- Incorrect: this.dateTime = new Date(sec);
- Correct: this.dateTime = new Date(sec * 1000);
- Reason: Date requires milliseconds but previously, seconds were provided.
- */
this.dateTime = new Date(sec * 1000);
} else {
this.dateTime = null;
@@ -91,7 +84,7 @@ public abstract class AbstractWeather extends AbstractResponse {
JSONArray weatherArray = (jsonObj != null) ? jsonObj.optJSONArray(JSON_WEATHER) : new JSONArray();
this.weatherList = (weatherArray != null) ? new ArrayListtrue
if date/time is available, otherwise false
.
*/
public boolean hasDateTime() {
- return (this.dateTime != null);
+ return this.dateTime != null;
}
/**
* @return true
if Weather instance(s) is available, otherwise false
.
*/
public boolean hasWeatherInstance() {
- return (weatherCount != 0);
+ return weatherCount != 0;
}
/**
@@ -157,7 +150,7 @@ public abstract class AbstractWeather extends AbstractResponse {
}
Clouds(JSONObject jsonObj) {
- this.percentOfClouds = (float) jsonObj.optDouble(this.JSON_CLOUDS_ALL, Double.NaN);
+ this.percentOfClouds = (float) jsonObj.optDouble(JSON_CLOUDS_ALL, Double.NaN);
}
/**
@@ -166,7 +159,7 @@ public abstract class AbstractWeather extends AbstractResponse {
* @return true
if data available, otherwise false
*/
public boolean hasPercentageOfClouds() {
- return (this.percentOfClouds != Float.NaN);
+ return !Float.isNaN(this.percentOfClouds);
}
/**
@@ -199,8 +192,8 @@ public abstract class AbstractWeather extends AbstractResponse {
}
Coord(JSONObject jsonObj) {
- this.lat = (float) jsonObj.optDouble(this.JSON_COORD_LATITUDE, Double.NaN);
- this.lon = (float) jsonObj.optDouble(this.JSON_COORD_LONGITUDE, Double.NaN);
+ this.lat = (float) jsonObj.optDouble(JSON_COORD_LATITUDE, Double.NaN);
+ this.lon = (float) jsonObj.optDouble(JSON_COORD_LONGITUDE, Double.NaN);
}
/**
@@ -209,7 +202,7 @@ public abstract class AbstractWeather extends AbstractResponse {
* @return true
if data available, otherwise false
*/
public boolean hasLatitude() {
- return (this.lat != Float.NaN);
+ return !Float.isNaN(this.lat);
}
/**
@@ -218,7 +211,7 @@ public abstract class AbstractWeather extends AbstractResponse {
* @return true
if data available, otherwise false
*/
public boolean hasLongitude() {
- return (this.lon != Float.NaN);
+ return !Float.isNaN(this.lon);
}
/**
@@ -268,11 +261,11 @@ public abstract class AbstractWeather extends AbstractResponse {
}
Main(JSONObject jsonObj) {
- this.temp = (float) jsonObj.optDouble(this.JSON_MAIN_TEMP, Double.NaN);
- this.minTemp = (float) jsonObj.optDouble(this.JSON_MAIN_TEMP_MIN, Double.NaN);
- this.maxTemp = (float) jsonObj.optDouble(this.JSON_MAIN_TEMP_MAX, Double.NaN);
- this.pressure = (float) jsonObj.optDouble(this.JSON_MAIN_PRESSURE, Double.NaN);
- this.humidity = (float) jsonObj.optDouble(this.JSON_MAIN_HUMIDITY, Double.NaN);
+ this.temp = (float) jsonObj.optDouble(JSON_MAIN_TEMP, Double.NaN);
+ this.minTemp = (float) jsonObj.optDouble(JSON_MAIN_TEMP_MIN, Double.NaN);
+ this.maxTemp = (float) jsonObj.optDouble(JSON_MAIN_TEMP_MAX, Double.NaN);
+ this.pressure = (float) jsonObj.optDouble(JSON_MAIN_PRESSURE, Double.NaN);
+ this.humidity = (float) jsonObj.optDouble(JSON_MAIN_HUMIDITY, Double.NaN);
}
/**
@@ -281,7 +274,7 @@ public abstract class AbstractWeather extends AbstractResponse {
* @return true
if data available, otherwise false
*/
public boolean hasTemperature() {
- return (this.temp != Float.NaN);
+ return !Float.isNaN(this.temp);
}
/**
@@ -290,7 +283,7 @@ public abstract class AbstractWeather extends AbstractResponse {
* @return true
if data available, otherwise false
*/
public boolean hasMinTemperature() {
- return (this.minTemp != Float.NaN);
+ return !Float.isNaN(this.minTemp);
}
/**
@@ -299,7 +292,7 @@ public abstract class AbstractWeather extends AbstractResponse {
* @return true
if data available, otherwise false
*/
public boolean hasMaxTemperature() {
- return (this.maxTemp != Float.NaN);
+ return !Float.isNaN(this.maxTemp);
}
/**
@@ -308,7 +301,7 @@ public abstract class AbstractWeather extends AbstractResponse {
* @return true
if data available, otherwise false
*/
public boolean hasPressure() {
- return (this.pressure != Float.NaN);
+ return !Float.isNaN(this.pressure);
}
/**
@@ -317,7 +310,7 @@ public abstract class AbstractWeather extends AbstractResponse {
* @return true
if data available, otherwise false
*/
public boolean hasHumidity() {
- return (this.humidity != Float.NaN);
+ return !Float.isNaN(this.humidity);
}
/**
@@ -395,10 +388,10 @@ public abstract class AbstractWeather extends AbstractResponse {
}
Weather(JSONObject jsonObj) {
- this.id = jsonObj.optInt(this.JSON_WEATHER_ID, Integer.MIN_VALUE);
- this.name = jsonObj.optString(this.JSON_WEATHER_MAIN, null);
- this.description = jsonObj.optString(this.JSON_WEATHER_DESCRIPTION, null);
- this.icon = jsonObj.optString(this.JSON_WEATHER_ICON, null);
+ this.id = jsonObj.optInt(JSON_WEATHER_ID, Integer.MIN_VALUE);
+ this.name = jsonObj.optString(JSON_WEATHER_MAIN, null);
+ this.description = jsonObj.optString(JSON_WEATHER_DESCRIPTION, null);
+ this.icon = jsonObj.optString(JSON_WEATHER_ICON, null);
}
/**
@@ -407,7 +400,7 @@ public abstract class AbstractWeather extends AbstractResponse {
* @return true
if data available, otherwise false
.
*/
public boolean hasWeatherCode() {
- return (this.id != Integer.MIN_VALUE);
+ return this.id != Integer.MIN_VALUE;
}
/**
@@ -416,7 +409,7 @@ public abstract class AbstractWeather extends AbstractResponse {
* @return true
if data available, otherwise false
.
*/
public boolean hasWeatherName() {
- return (this.name != null && (!this.name.equals("")));
+ return this.name != null && (! "".equals(this.name));
}
/**
@@ -425,7 +418,7 @@ public abstract class AbstractWeather extends AbstractResponse {
* @return true
if data available, otherwise false
.
*/
public boolean hasWeatherDescription() {
- return (this.description != null && (!this.description.equals("")));
+ return this.description != null && (! "".equals(this.description));
}
/**
@@ -434,7 +427,7 @@ public abstract class AbstractWeather extends AbstractResponse {
* @return true
if data available, otherwise false
.
*/
public boolean hasWeatherIconName() {
- return (this.icon != null && (!this.icon.equals("")));
+ return this.icon != null && (! "".equals(this.icon));
}
/**
@@ -488,8 +481,8 @@ public abstract class AbstractWeather extends AbstractResponse {
}
Wind(JSONObject jsonObj) {
- this.speed = (float) jsonObj.optDouble(this.JSON_WIND_SPEED, Double.NaN);
- this.degree = (float) jsonObj.optDouble(this.JSON_WIND_DEGREE, Double.NaN);
+ this.speed = (float) jsonObj.optDouble(JSON_WIND_SPEED, Double.NaN);
+ this.degree = (float) jsonObj.optDouble(JSON_WIND_DEGREE, Double.NaN);
}
/**
@@ -498,7 +491,7 @@ public abstract class AbstractWeather extends AbstractResponse {
* @return true
if data available, otherwise false
.
*/
public boolean hasWindSpeed() {
- return (this.speed != Float.NaN);
+ return !Float.isNaN(this.speed);
}
/**
@@ -507,7 +500,7 @@ public abstract class AbstractWeather extends AbstractResponse {
* @return true
if data available, otherwise false
.
*/
public boolean hasWindDegree() {
- return (this.hasWindSpeed() && (this.degree != Float.NaN));
+ return this.hasWindSpeed() && (! Float.isNaN(this.degree));
}
/**
diff --git a/src/main/java/net/aksingh/owmjapis/DailyForecast.java b/src/main/java/net/aksingh/owmjapis/DailyForecast.java
index 2450e26..c66f940 100644
--- a/src/main/java/net/aksingh/owmjapis/DailyForecast.java
+++ b/src/main/java/net/aksingh/owmjapis/DailyForecast.java
@@ -63,9 +63,9 @@ public class DailyForecast extends AbstractForecast {
DailyForecast(JSONObject jsonObj) {
super(jsonObj);
- JSONArray dataArray = (jsonObj != null) ? jsonObj.optJSONArray(this.JSON_FORECAST_LIST) : new JSONArray();
+ JSONArray dataArray = (jsonObj != null) ? jsonObj.optJSONArray(JSON_FORECAST_LIST) : new JSONArray();
this.forecastList = (dataArray != null) ? new ArrayList
true
if Clouds instance is available, otherwise false
.
*/
public boolean hasCloudsInstance() {
- return (clouds != null);
+ return clouds != null;
}
/**
* @return true
if Main instance is available, otherwise false
.
*/
public boolean hasMainInstance() {
- return (main != null);
+ return main != null;
}
/**
* @return true
if Sys instance is available, otherwise false
.
*/
public boolean hasSysInstance() {
- return (sys != null);
+ return sys != null;
}
/**
* @return true
if Wind instance is available, otherwise false
.
*/
public boolean hasWindInstance() {
- return (wind != null);
+ return wind != null;
}
public String getDateTimeText() {
@@ -253,9 +253,9 @@ public class HourlyForecast extends AbstractForecast {
* @since 2.5.0.1
*/
public static class Main extends AbstractForecast.Forecast.Main {
- private final String JSON_MAIN_SEA_LEVEL = "sea_level";
- private final String JSON_MAIN_GRND_LEVEL = "grnd_level";
- private final String JSON_MAIN_TMP_KF = "temp_kf";
+ private static final String JSON_MAIN_SEA_LEVEL = "sea_level";
+ private static final String JSON_MAIN_GRND_LEVEL = "grnd_level";
+ private static final String JSON_MAIN_TMP_KF = "temp_kf";
private final float seaLevel;
private final float groundLevel;
@@ -272,21 +272,21 @@ public class HourlyForecast extends AbstractForecast {
Main(JSONObject jsonObj) {
super(jsonObj);
- this.seaLevel = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_MAIN_SEA_LEVEL, Float.NaN) : Float.NaN;
- this.groundLevel = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_MAIN_GRND_LEVEL, Float.NaN) : Float.NaN;
- this.tempKF = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_MAIN_TMP_KF, Float.NaN) : Float.NaN;
+ this.seaLevel = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_MAIN_SEA_LEVEL, Float.NaN) : Float.NaN;
+ this.groundLevel = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_MAIN_GRND_LEVEL, Float.NaN) : Float.NaN;
+ this.tempKF = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_MAIN_TMP_KF, Float.NaN) : Float.NaN;
}
public boolean hasSeaLevel() {
- return (this.seaLevel != Float.NaN);
+ return !Float.isNaN(this.seaLevel);
}
public boolean hasGroundLevel() {
- return (this.groundLevel != Float.NaN);
+ return !Float.isNaN(this.groundLevel);
}
public boolean hasTempKF() {
- return (this.tempKF != Float.NaN);
+ return !Float.isNaN(this.tempKF);
}
public float getSeaLevel() {
@@ -323,7 +323,8 @@ public class HourlyForecast extends AbstractForecast {
* @since 2.5.0.1
*/
public static class Sys implements Serializable {
- private final String JSON_SYS_POD = "pod";
+ private static final String JSON_SYS_POD = "pod";
+
private final String pod;
Sys() {
@@ -331,11 +332,11 @@ public class HourlyForecast extends AbstractForecast {
}
Sys(JSONObject jsonObj) {
- this.pod = (jsonObj != null) ? jsonObj.optString(this.JSON_SYS_POD, null) : null;
+ this.pod = (jsonObj != null) ? jsonObj.optString(JSON_SYS_POD, null) : null;
}
public boolean hasPod() {
- return (this.pod != null && (!this.pod.equals("")));
+ return this.pod != null && (! "".equals(this.pod));
}
public String getPod() {