diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 7fb11b5..caceddf 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -13,10 +13,10 @@ name: "CodeQL"
on:
push:
- branches: [ master ]
+ branches: [ dev ]
pull_request:
# The branches below must be a subset of the branches above
- branches: [ master ]
+ branches: [ dev ]
schedule:
- cron: '27 20 * * 1'
diff --git a/README.md b/README.md
index 77be6ea..a7056ed 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ Paid:
com.github.prominence
openweathermap-api
- 2.0.0
+ 2.0.0-SNAPSHOT
```
diff --git a/docs/SNAPSHOT.md b/docs/SNAPSHOT.md
index 2027145..2d86235 100644
--- a/docs/SNAPSHOT.md
+++ b/docs/SNAPSHOT.md
@@ -105,6 +105,7 @@ You are able to set preferable options(via chain methods) and execute appropriat
|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `getState()` | Returns short weather description. Example: `Clear`. |
| `getDescription()` | Returns weather description. Example: `clear sky`. |
+| `getWeatherIconId()` | Returns a weather state ID. Examples: `01d`, `01n`, `11n`, etc. |
| `getWeatherIconUrl()` | Returns a link to weather icon hosted on https://openweathermap.org website. |
| `getCalculatedOn()` | Returns `LocalDateTime` object with data calculation time. |
| `getTemperature()` | Returns `Temperature` instance that contains information about temperature. Available fields: `value`, `maxTemperature`, `minTemperature`, `feelsLike` and `unit`. |
@@ -188,6 +189,7 @@ A forecast for Minsk with 15 timestamps.
|-------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `getState()` | Returns short weather description. Example: `Clear`. |
| `getDescription()` | Returns weather description. Example: `clear sky`. |
+| `getWeatherIconId()` | Returns a weather state ID. Examples: `01d`, `01n`, `11n`, etc. |
| `getWeatherIconUrl()` | Returns a link to weather icon hosted on https://openweathermap.org website. |
| `getForecastTime()` | Returns `LocalDateTime` object with weather forecast time. |
| `getTemperature()` | Returns `Temperature` instance that contains information about temperature. Available fields: `value`, `maxTemperature`, `minTemperature`, `feelsLike` and `unit`. |
diff --git a/pom.xml b/pom.xml
index 5d60bd0..6c2a7c2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.github.prominence
openweathermap-api
- 2.0.0
+ 2.0.0-SNAPSHOT
jar
Java OpenWeatherMap API
diff --git a/src/main/java/com/github/prominence/openweathermap/api/enums/UnitSystem.java b/src/main/java/com/github/prominence/openweathermap/api/enums/UnitSystem.java
index 94e2781..8c1ce94 100644
--- a/src/main/java/com/github/prominence/openweathermap/api/enums/UnitSystem.java
+++ b/src/main/java/com/github/prominence/openweathermap/api/enums/UnitSystem.java
@@ -69,9 +69,9 @@ public enum UnitSystem {
public String getTemperatureUnit() {
switch (this) {
case METRIC:
- return "℃";
+ return "°C";
case IMPERIAL:
- return "℉";
+ return "°F";
case STANDARD:
default:
return "K";
diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/forecast/WeatherForecast.java b/src/main/java/com/github/prominence/openweathermap/api/model/forecast/WeatherForecast.java
index 7c12652..1a3b07e 100644
--- a/src/main/java/com/github/prominence/openweathermap/api/model/forecast/WeatherForecast.java
+++ b/src/main/java/com/github/prominence/openweathermap/api/model/forecast/WeatherForecast.java
@@ -33,7 +33,7 @@ import java.util.Objects;
public class WeatherForecast {
private String state;
private String description;
- private String weatherIconUrl;
+ private String weatherIconId;
private LocalDateTime forecastTime;
@@ -113,22 +113,34 @@ public class WeatherForecast {
this.description = description;
}
+ /**
+ * Gets weather icon ID.
+ *
+ * @return the weather icon ID
+ */
+ public String getWeatherIconId() {
+ return weatherIconId;
+ }
+
+ /**
+ * Sets weather icon ID.
+ *
+ * @param weatherIconId the weather icon ID
+ */
+ public void setWeatherIconId(String weatherIconId) {
+ this.weatherIconId = weatherIconId;
+ }
+
/**
* Gets weather icon url.
*
* @return the weather icon url
*/
public String getWeatherIconUrl() {
- return weatherIconUrl;
- }
-
- /**
- * Sets weather icon url.
- *
- * @param weatherIconUrl the weather icon url
- */
- public void setWeatherIconUrl(String weatherIconUrl) {
- this.weatherIconUrl = weatherIconUrl;
+ if (weatherIconId != null) {
+ return "https://openweathermap.org/img/w/" + weatherIconId + ".png";
+ }
+ return null;
}
/**
@@ -318,7 +330,7 @@ public class WeatherForecast {
WeatherForecast that = (WeatherForecast) o;
return Objects.equals(state, that.state) &&
Objects.equals(description, that.description) &&
- Objects.equals(weatherIconUrl, that.weatherIconUrl) &&
+ Objects.equals(weatherIconId, that.weatherIconId) &&
Objects.equals(forecastTime, that.forecastTime) &&
Objects.equals(temperature, that.temperature) &&
Objects.equals(atmosphericPressure, that.atmosphericPressure) &&
@@ -333,7 +345,7 @@ public class WeatherForecast {
@Override
public int hashCode() {
- return Objects.hash(state, description, weatherIconUrl, forecastTime, temperature, atmosphericPressure, humidity, wind, rain, snow, clouds, forecastTimeISO, dayTime);
+ return Objects.hash(state, description, weatherIconId, forecastTime, temperature, atmosphericPressure, humidity, wind, rain, snow, clouds, forecastTimeISO, dayTime);
}
@Override
diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/weather/Weather.java b/src/main/java/com/github/prominence/openweathermap/api/model/weather/Weather.java
index b2f5ff0..76cc009 100644
--- a/src/main/java/com/github/prominence/openweathermap/api/model/weather/Weather.java
+++ b/src/main/java/com/github/prominence/openweathermap/api/model/weather/Weather.java
@@ -33,7 +33,7 @@ import java.util.Objects;
public class Weather {
private String state;
private String description;
- private String weatherIconUrl;
+ private String weatherIconId;
private LocalDateTime calculatedOn;
@@ -112,22 +112,34 @@ public class Weather {
this.description = description;
}
+ /**
+ * Gets weather icon ID.
+ *
+ * @return the weather icon ID
+ */
+ public String getWeatherIconId() {
+ return weatherIconId;
+ }
+
+ /**
+ * Sets weather icon ID.
+ *
+ * @param weatherIconId the weather icon ID
+ */
+ public void setWeatherIconId(String weatherIconId) {
+ this.weatherIconId = weatherIconId;
+ }
+
/**
* Gets weather icon url.
*
* @return the weather icon url
*/
public String getWeatherIconUrl() {
- return weatherIconUrl;
- }
-
- /**
- * Sets weather icon url.
- *
- * @param weatherIconUrl the weather icon url
- */
- public void setWeatherIconUrl(String weatherIconUrl) {
- this.weatherIconUrl = weatherIconUrl;
+ if (weatherIconId != null) {
+ return "http://openweathermap.org/img/w/" + weatherIconId + ".png";
+ }
+ return null;
}
/**
@@ -299,7 +311,7 @@ public class Weather {
Weather weather = (Weather) o;
return Objects.equals(state, weather.state) &&
Objects.equals(description, weather.description) &&
- Objects.equals(weatherIconUrl, weather.weatherIconUrl) &&
+ Objects.equals(weatherIconId, weather.weatherIconId) &&
Objects.equals(calculatedOn, weather.calculatedOn) &&
Objects.equals(temperature, weather.temperature) &&
Objects.equals(atmosphericPressure, weather.atmosphericPressure) &&
@@ -313,7 +325,7 @@ public class Weather {
@Override
public int hashCode() {
- return Objects.hash(state, description, weatherIconUrl, calculatedOn, temperature, atmosphericPressure, humidity, wind, rain, snow, clouds, location);
+ return Objects.hash(state, description, weatherIconId, calculatedOn, temperature, atmosphericPressure, humidity, wind, rain, snow, clouds, location);
}
@Override
diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastResponseMapper.java b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastResponseMapper.java
index 8bcf504..ea07b64 100644
--- a/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastResponseMapper.java
+++ b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastResponseMapper.java
@@ -138,7 +138,7 @@ public class FiveDayThreeHourStepForecastResponseMapper {
weatherNode.get("main").asText(),
weatherNode.get("description").asText()
);
- weatherForecast.setWeatherIconUrl("https://openweathermap.org/img/w/" + weatherNode.get("icon").asText() + ".png");
+ weatherForecast.setWeatherIconId(weatherNode.get("icon").asText());
JsonNode mainNode = rootNode.get("main");
weatherForecast.setTemperature(parseTemperature(mainNode));
diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java
index 690edc4..67b8477 100644
--- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java
+++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java
@@ -117,7 +117,7 @@ public class CurrentWeatherResponseMapper {
private Weather getSingle(JsonNode rootNode) {
JsonNode weatherState = rootNode.get("weather").get(0);
Weather weather = Weather.forValue(weatherState.get("main").asText(), weatherState.get("description").asText());
- weather.setWeatherIconUrl("http://openweathermap.org/img/w/" + weatherState.get("icon").asText() + ".png");
+ weather.setWeatherIconId(weatherState.get("icon").asText());
weather.setTemperature(parseTemperature(rootNode));
weather.setAtmosphericPressure(parsePressure(rootNode));
diff --git a/src/test/java/com/github/prominence/openweathermap/api/model/forecast/WeatherForecastUnitTest.java b/src/test/java/com/github/prominence/openweathermap/api/model/forecast/WeatherForecastUnitTest.java
index 0204f5c..d0caceb 100644
--- a/src/test/java/com/github/prominence/openweathermap/api/model/forecast/WeatherForecastUnitTest.java
+++ b/src/test/java/com/github/prominence/openweathermap/api/model/forecast/WeatherForecastUnitTest.java
@@ -73,11 +73,15 @@ public class WeatherForecastUnitTest {
}
@Test
- public void whenSetIconUrl_thenValueIsSet() {
+ public void whenSetIconId_thenValueIsSet() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
- weatherForecast.setWeatherIconUrl("test");
+ Assert.assertNull(weatherForecast.getWeatherIconId());
+ Assert.assertNull(weatherForecast.getWeatherIconUrl());
- Assert.assertEquals("test", weatherForecast.getWeatherIconUrl());
+ weatherForecast.setWeatherIconId("02n");
+
+ Assert.assertEquals("02n", weatherForecast.getWeatherIconId());
+ Assert.assertNotNull(weatherForecast.getWeatherIconUrl());
}
@Test
@@ -258,11 +262,11 @@ public class WeatherForecastUnitTest {
Assert.assertTrue(one.equals(two));
- one.setWeatherIconUrl("1");
+ one.setWeatherIconId("1");
Assert.assertFalse(one.equals(two));
- two.setWeatherIconUrl("1");
+ two.setWeatherIconId("1");
Assert.assertTrue(one.equals(two));
diff --git a/src/test/java/com/github/prominence/openweathermap/api/model/weather/WeatherUnitTest.java b/src/test/java/com/github/prominence/openweathermap/api/model/weather/WeatherUnitTest.java
index 10719bc..47547cf 100644
--- a/src/test/java/com/github/prominence/openweathermap/api/model/weather/WeatherUnitTest.java
+++ b/src/test/java/com/github/prominence/openweathermap/api/model/weather/WeatherUnitTest.java
@@ -76,11 +76,15 @@ public class WeatherUnitTest {
}
@Test
- public void whenSetIconUrl_thenValueIsSet() {
+ public void whenSetIconId_thenValueIsSet() {
final Weather weather = Weather.forValue("state", "desc");
- weather.setWeatherIconUrl("test");
+ Assert.assertNull(weather.getWeatherIconId());
+ Assert.assertNull(weather.getWeatherIconUrl());
- Assert.assertEquals("test", weather.getWeatherIconUrl());
+ weather.setWeatherIconId("11d");
+
+ Assert.assertEquals("11d", weather.getWeatherIconId());
+ Assert.assertNotNull(weather.getWeatherIconUrl());
}
@Test
@@ -235,11 +239,11 @@ public class WeatherUnitTest {
Assert.assertTrue(one.equals(two));
- one.setWeatherIconUrl("1");
+ one.setWeatherIconId("1");
Assert.assertFalse(one.equals(two));
- two.setWeatherIconUrl("1");
+ two.setWeatherIconId("1");
Assert.assertTrue(one.equals(two));