Skip to content

Commit e594ffb

Browse files
authored
2.1.1 version implementation.
1 parent 4cfa8ab commit e594ffb

File tree

8 files changed

+575
-36
lines changed

8 files changed

+575
-36
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ Paid:
2626
<dependency>
2727
<groupId>com.github.prominence</groupId>
2828
<artifactId>openweathermap-api</artifactId>
29-
<version>2.1.0</version>
29+
<version>2.1.1</version>
3030
</dependency>
3131
```
3232

3333
### Gradle coordinates:
3434

3535
```groovy
36-
compile('com.github.prominence:openweathermap-api:2.1.0')
36+
compile('com.github.prominence:openweathermap-api:2.1.1')
3737
```
3838

3939
### Documentation

docs/Release_2.1.1.md

Lines changed: 486 additions & 0 deletions
Large diffs are not rendered by default.

docs/SNAPSHOT.md

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
<dependency>
1010
<groupId>com.github.prominence</groupId>
1111
<artifactId>openweathermap-api</artifactId>
12-
<version>2.1.0</version>
12+
<version>2.1.1-SNAPSHOT</version>
1313
</dependency>
1414
```
1515

1616
### Gradle coordinates:
1717

1818
```groovy
19-
compile('com.github.prominence:openweathermap-api:2.1.0')
19+
compile('com.github.prominence:openweathermap-api:2.1.1-SNAPSHOT')
2020
```
2121

2222
### How to use:
@@ -332,38 +332,40 @@ You are able to set preferable options(via chain methods) and execute appropriat
332332

333333
`com.github.prominence.openweathermap.api.model.onecall.current.Hourly`'s useful public methods(setters are not listed):
334334

335-
| Method | Description |
336-
|-----------------------------------|---------------------------------------------------------------------------------------------------|
337-
| `getForecastTime()` | Returns `LocalDateTime` object with weather forecast time. |
338-
| `getWeatherState()` | Returns `WeatherState` object with basic weather state information. |
339-
| `getTemperature()` | Returns `Temperature` object. Available fields: `value`, `feelsLike`, `dewPoint` and `unit`. |
340-
| `getAtmosphericPressure()` | Returns `AtmosphericPressure` object. Available fields: `seaLevelValue`. |
341-
| `getHumidity()` | Returns `Humidity` object. Available fields: `value` and `unit`. |
342-
| `getClouds()` | Returns `Clouds` object. Available fields: `value` and `unit`. |
343-
| `getUvIndex()` | Returns UV index value. |
344-
| `getVisibilityInMetres()` | Returns visibility in metres. |
345-
| `getWind()` | Returns `Wind` object. Available fields: `speed`, `degrees`, `gust` and `unit`. |
346-
| `getProbabilityOfPrecipitation()` | Returns probability of precipitation(not percentage). |
347-
| `getRain()` | Returns `Rain` object. Available fields: `oneHourLevel` and `unit`. |
348-
| `getSnow()` | Returns `Snow` object. Available fields: `oneHourLevel` and `unit`. |
335+
| Method | Description |
336+
|-----------------------------------------------|---------------------------------------------------------------------------------------------------|
337+
| `getForecastTime()` | Returns `LocalDateTime` object with weather forecast time. |
338+
| `getWeatherState()` | Returns `WeatherState` object with basic weather state information. |
339+
| `getTemperature()` | Returns `Temperature` object. Available fields: `value`, `feelsLike`, `dewPoint` and `unit`. |
340+
| `getAtmosphericPressure()` | Returns `AtmosphericPressure` object. Available fields: `seaLevelValue`. |
341+
| `getHumidity()` | Returns `Humidity` object. Available fields: `value` and `unit`. |
342+
| `getClouds()` | Returns `Clouds` object. Available fields: `value` and `unit`. |
343+
| `getUvIndex()` | Returns UV index value. |
344+
| `getVisibilityInMetres()` | Returns visibility in metres. |
345+
| `getWind()` | Returns `Wind` object. Available fields: `speed`, `degrees`, `gust` and `unit`. |
346+
| `getProbabilityOfPrecipitation()` | Returns probability of precipitation(not percentage). |
347+
| `getProbabilityOfPrecipitationPercentage()` | Returns probability of precipitation percentage. |
348+
| `getRain()` | Returns `Rain` object. Available fields: `oneHourLevel` and `unit`. |
349+
| `getSnow()` | Returns `Snow` object. Available fields: `oneHourLevel` and `unit`. |
349350

350351
`com.github.prominence.openweathermap.api.model.onecall.current.Daily`'s useful public methods(setters are not listed):
351352

352-
| Method | Description |
353-
|-----------------------------------|---------------------------------------------------------------------------------------------------|
354-
| `getForecastTime()` | Returns `LocalDateTime` object with weather forecast time. |
355-
| `getSunriseTime()` | Returns `LocalDateTime` object with sunrise time. |
356-
| `getSunsetTime()` | Returns `LocalDateTime` object with sunset time. |
357-
| `getWeatherState()` | Returns `WeatherState` object with basic weather state information. |
358-
| `getTemperature()` | Returns `DailyTemperature` object. Available fields: `value`, `feelsLike`, `dewPoint` and `unit`. |
359-
| `getAtmosphericPressure()` | Returns `AtmosphericPressure` object. Available fields: `seaLevelValue`. |
360-
| `getHumidity()` | Returns `Humidity` object. Available fields: `value` and `unit`. |
361-
| `getWind()` | Returns `Wind` object. Available fields: `speed`, `degrees`, `gust` and `unit`. |
362-
| `getClouds()` | Returns `Clouds` object. Available fields: `value` and `unit`. |
363-
| `getUvIndex()` | Returns UV index value. |
364-
| `getProbabilityOfPrecipitation()` | Returns probability of precipitation(not percentage). |
365-
| `getRain()` | Returns `DailyRain` object. Available fields: `value`. |
366-
| `getSnow()` | Returns `DailySnow` object. Available fields: `value`. |
353+
| Method | Description |
354+
|-----------------------------------------------|---------------------------------------------------------------------------------------------------|
355+
| `getForecastTime()` | Returns `LocalDateTime` object with weather forecast time. |
356+
| `getSunriseTime()` | Returns `LocalDateTime` object with sunrise time. |
357+
| `getSunsetTime()` | Returns `LocalDateTime` object with sunset time. |
358+
| `getWeatherState()` | Returns `WeatherState` object with basic weather state information. |
359+
| `getTemperature()` | Returns `DailyTemperature` object. Available fields: `value`, `feelsLike`, `dewPoint` and `unit`. |
360+
| `getAtmosphericPressure()` | Returns `AtmosphericPressure` object. Available fields: `seaLevelValue`. |
361+
| `getHumidity()` | Returns `Humidity` object. Available fields: `value` and `unit`. |
362+
| `getWind()` | Returns `Wind` object. Available fields: `speed`, `degrees`, `gust` and `unit`. |
363+
| `getClouds()` | Returns `Clouds` object. Available fields: `value` and `unit`. |
364+
| `getUvIndex()` | Returns UV index value. |
365+
| `getProbabilityOfPrecipitation()` | Returns probability of precipitation(not percentage). |
366+
| `getProbabilityOfPrecipitationPercentage()` | Returns probability of precipitation percentage. |
367+
| `getRain()` | Returns `DailyRain` object. Available fields: `value`. |
368+
| `getSnow()` | Returns `DailySnow` object. Available fields: `value`. |
367369

368370
`com.github.prominence.openweathermap.api.model.onecall.current.Alert`'s useful public methods(setters are not listed):
369371

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.prominence</groupId>
88
<artifactId>openweathermap-api</artifactId>
9-
<version>2.1.0</version>
9+
<version>2.1.1</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Java OpenWeatherMap API</name>

src/main/java/com/github/prominence/openweathermap/api/model/onecall/current/Daily.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,19 @@ public void setProbabilityOfPrecipitation(Double probabilityOfPrecipitation) {
254254
this.probabilityOfPrecipitation = probabilityOfPrecipitation;
255255
}
256256

257+
/**
258+
* Gets probability of precipitation percentage.
259+
*
260+
* @return the probability of precipitation percentage
261+
*/
262+
public Byte getProbabilityOfPrecipitationPercentage() {
263+
if (probabilityOfPrecipitation != null) {
264+
return (byte)(probabilityOfPrecipitation * 100);
265+
}
266+
267+
return null;
268+
}
269+
257270
/**
258271
* Gets rain.
259272
*

src/main/java/com/github/prominence/openweathermap/api/model/onecall/current/Hourly.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,25 @@ public Double getProbabilityOfPrecipitation() {
225225
* @param probabilityOfPrecipitation the probability of precipitation
226226
*/
227227
public void setProbabilityOfPrecipitation(Double probabilityOfPrecipitation) {
228+
if (probabilityOfPrecipitation != null && (probabilityOfPrecipitation < 0 || probabilityOfPrecipitation > 100)) {
229+
throw new IllegalArgumentException("Probability of precipitation value must be in [0, 100] range.");
230+
}
228231
this.probabilityOfPrecipitation = probabilityOfPrecipitation;
229232
}
230233

234+
/**
235+
* Gets probability of precipitation percentage.
236+
*
237+
* @return the probability of precipitation percentage
238+
*/
239+
public Byte getProbabilityOfPrecipitationPercentage() {
240+
if (probabilityOfPrecipitation != null) {
241+
return (byte)(probabilityOfPrecipitation * 100);
242+
}
243+
244+
return null;
245+
}
246+
231247
/**
232248
* Gets rain.
233249
*

src/test/java/com/github/prominence/openweathermap/api/model/onecall/current/DailyUnitTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,16 @@ public void getIllegalUvIndexValue() {
141141
@Test
142142
public void getProbabilityOfPrecipitation() {
143143
final Daily daily = new Daily();
144-
final double pop = 70.5;
144+
final double pop = 0.84;
145145
daily.setProbabilityOfPrecipitation(pop);
146146

147147
assertEquals(pop, daily.getProbabilityOfPrecipitation(), 0.00001);
148+
assertEquals((byte) 84, daily.getProbabilityOfPrecipitationPercentage());
148149

149150
daily.setProbabilityOfPrecipitation(null);
150151

151152
assertNull(daily.getProbabilityOfPrecipitation());
153+
assertNull(daily.getProbabilityOfPrecipitationPercentage());
152154
}
153155

154156
@Test

src/test/java/com/github/prominence/openweathermap/api/model/onecall/current/HourlyUnitTest.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,30 @@ public void getWind() {
117117
@Test
118118
public void getProbabilityOfPrecipitation() {
119119
final Hourly hourly = new Hourly();
120-
final double pop = 42.0;
120+
final double pop = 0.84;
121121
hourly.setProbabilityOfPrecipitation(pop);
122122

123123
assertEquals(pop, hourly.getProbabilityOfPrecipitation(), 0.00001);
124+
assertEquals((byte) 84, hourly.getProbabilityOfPrecipitationPercentage());
125+
126+
hourly.setProbabilityOfPrecipitation(null);
127+
128+
assertNull(hourly.getProbabilityOfPrecipitation());
129+
assertNull(hourly.getProbabilityOfPrecipitationPercentage());
130+
}
131+
132+
@Test
133+
public void getIllegalProbabilityOfPrecipitationValue_negative() {
134+
final Hourly daily = new Hourly();
135+
136+
assertThrows(IllegalArgumentException.class, () -> daily.setProbabilityOfPrecipitation(-20.0));
137+
}
138+
139+
@Test
140+
public void getIllegalProbabilityOfPrecipitationValue_tooBig() {
141+
final Hourly daily = new Hourly();
142+
143+
assertThrows(IllegalArgumentException.class, () -> daily.setProbabilityOfPrecipitation(120.0));
124144
}
125145

126146
@Test

0 commit comments

Comments
 (0)