mirror of
https://github.com/Prominence/openweathermap-java-api.git
synced 2026-07-03 03:06:45 +03:00
Wrote documentation.
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Alexey Zinchenko
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.prominence.openweathermap.api.enums;
|
||||
|
||||
@Deprecated
|
||||
public enum TimeFrame {
|
||||
YEAR,
|
||||
MONTH,
|
||||
DAY,
|
||||
HOUR,
|
||||
MINUTE,
|
||||
SECOND
|
||||
}
|
||||
+57
-56
@@ -28,19 +28,20 @@ import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
public class WeatherForecast {
|
||||
private LocalDateTime forecastTime;
|
||||
private Temperature temperature;
|
||||
private AtmosphericPressure atmosphericPressure;
|
||||
private Humidity humidity;
|
||||
|
||||
private String state;
|
||||
private String description;
|
||||
private String weatherIconUrl;
|
||||
|
||||
private Clouds clouds;
|
||||
private LocalDateTime forecastTime;
|
||||
|
||||
private Temperature temperature;
|
||||
private AtmosphericPressure atmosphericPressure;
|
||||
private Humidity humidity;
|
||||
|
||||
private Wind wind;
|
||||
private Snow snow;
|
||||
private Rain rain;
|
||||
private Snow snow;
|
||||
private Clouds clouds;
|
||||
|
||||
private String forecastTimeISO;
|
||||
private DayTime dayTime;
|
||||
@@ -60,6 +61,36 @@ public class WeatherForecast {
|
||||
return new WeatherForecast(state, description);
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
if (state == null) {
|
||||
throw new IllegalArgumentException("State must be not null.");
|
||||
}
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
if (description == null) {
|
||||
throw new IllegalArgumentException("Description must be not null.");
|
||||
}
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getWeatherIconUrl() {
|
||||
return weatherIconUrl;
|
||||
}
|
||||
|
||||
public void setWeatherIconUrl(String weatherIconUrl) {
|
||||
this.weatherIconUrl = weatherIconUrl;
|
||||
}
|
||||
|
||||
public LocalDateTime getForecastTime() {
|
||||
return forecastTime;
|
||||
}
|
||||
@@ -92,44 +123,6 @@ public class WeatherForecast {
|
||||
this.humidity = humidity;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
if (state == null) {
|
||||
throw new IllegalArgumentException("State must be not null.");
|
||||
}
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
if (description == null) {
|
||||
throw new IllegalArgumentException("Description must be not null.");
|
||||
}
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getWeatherIconUrl() {
|
||||
return weatherIconUrl;
|
||||
}
|
||||
|
||||
public void setWeatherIconUrl(String weatherIconUrl) {
|
||||
this.weatherIconUrl = weatherIconUrl;
|
||||
}
|
||||
|
||||
public Clouds getClouds() {
|
||||
return clouds;
|
||||
}
|
||||
|
||||
public void setClouds(Clouds clouds) {
|
||||
this.clouds = clouds;
|
||||
}
|
||||
|
||||
public Wind getWind() {
|
||||
return wind;
|
||||
}
|
||||
@@ -138,6 +131,14 @@ public class WeatherForecast {
|
||||
this.wind = wind;
|
||||
}
|
||||
|
||||
public Rain getRain() {
|
||||
return rain;
|
||||
}
|
||||
|
||||
public void setRain(Rain rain) {
|
||||
this.rain = rain;
|
||||
}
|
||||
|
||||
public Snow getSnow() {
|
||||
return snow;
|
||||
}
|
||||
@@ -146,12 +147,12 @@ public class WeatherForecast {
|
||||
this.snow = snow;
|
||||
}
|
||||
|
||||
public Rain getRain() {
|
||||
return rain;
|
||||
public Clouds getClouds() {
|
||||
return clouds;
|
||||
}
|
||||
|
||||
public void setRain(Rain rain) {
|
||||
this.rain = rain;
|
||||
public void setClouds(Clouds clouds) {
|
||||
this.clouds = clouds;
|
||||
}
|
||||
|
||||
public String getForecastTimeISO() {
|
||||
@@ -175,24 +176,24 @@ public class WeatherForecast {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
WeatherForecast that = (WeatherForecast) o;
|
||||
return Objects.equals(forecastTime, that.forecastTime) &&
|
||||
return Objects.equals(state, that.state) &&
|
||||
Objects.equals(description, that.description) &&
|
||||
Objects.equals(weatherIconUrl, that.weatherIconUrl) &&
|
||||
Objects.equals(forecastTime, that.forecastTime) &&
|
||||
Objects.equals(temperature, that.temperature) &&
|
||||
Objects.equals(atmosphericPressure, that.atmosphericPressure) &&
|
||||
Objects.equals(humidity, that.humidity) &&
|
||||
Objects.equals(state, that.state) &&
|
||||
Objects.equals(description, that.description) &&
|
||||
Objects.equals(weatherIconUrl, that.weatherIconUrl) &&
|
||||
Objects.equals(clouds, that.clouds) &&
|
||||
Objects.equals(wind, that.wind) &&
|
||||
Objects.equals(snow, that.snow) &&
|
||||
Objects.equals(rain, that.rain) &&
|
||||
Objects.equals(snow, that.snow) &&
|
||||
Objects.equals(clouds, that.clouds) &&
|
||||
Objects.equals(forecastTimeISO, that.forecastTimeISO) &&
|
||||
dayTime == that.dayTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(forecastTime, temperature, atmosphericPressure, humidity, state, description, weatherIconUrl, clouds, wind, snow, rain, forecastTimeISO, dayTime);
|
||||
return Objects.hash(state, description, weatherIconUrl, forecastTime, temperature, atmosphericPressure, humidity, wind, rain, snow, clouds, forecastTimeISO, dayTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -50,16 +50,16 @@ import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Weather {
|
||||
|
||||
private String state;
|
||||
private String description;
|
||||
private String weatherIconUrl;
|
||||
|
||||
private LocalDateTime requestedOn;
|
||||
private LocalDateTime calculatedOn;
|
||||
|
||||
private Temperature temperature;
|
||||
private AtmosphericPressure atmosphericPressure;
|
||||
private Humidity humidity;
|
||||
|
||||
private Wind wind;
|
||||
private Rain rain;
|
||||
private Snow snow;
|
||||
@@ -112,12 +112,12 @@ public class Weather {
|
||||
this.weatherIconUrl = weatherIconUrl;
|
||||
}
|
||||
|
||||
public LocalDateTime getRequestedOn() {
|
||||
return requestedOn;
|
||||
public LocalDateTime getCalculatedOn() {
|
||||
return calculatedOn;
|
||||
}
|
||||
|
||||
public void setRequestedOn(LocalDateTime requestedOn) {
|
||||
this.requestedOn = requestedOn;
|
||||
public void setCalculatedOn(LocalDateTime calculatedOn) {
|
||||
this.calculatedOn = calculatedOn;
|
||||
}
|
||||
|
||||
public Temperature getTemperature() {
|
||||
@@ -192,7 +192,7 @@ public class Weather {
|
||||
return Objects.equals(state, weather.state) &&
|
||||
Objects.equals(description, weather.description) &&
|
||||
Objects.equals(weatherIconUrl, weather.weatherIconUrl) &&
|
||||
Objects.equals(requestedOn, weather.requestedOn) &&
|
||||
Objects.equals(calculatedOn, weather.calculatedOn) &&
|
||||
Objects.equals(temperature, weather.temperature) &&
|
||||
Objects.equals(atmosphericPressure, weather.atmosphericPressure) &&
|
||||
Objects.equals(humidity, weather.humidity) &&
|
||||
@@ -205,7 +205,7 @@ public class Weather {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(state, description, weatherIconUrl, requestedOn, temperature, atmosphericPressure, humidity, wind, rain, snow, clouds, location);
|
||||
return Objects.hash(state, description, weatherIconUrl, calculatedOn, temperature, atmosphericPressure, humidity, wind, rain, snow, clouds, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
|
||||
|
||||
final JsonNode dtNode = rootNode.get("dt");
|
||||
if (dtNode != null) {
|
||||
weather.setRequestedOn(LocalDateTime.ofInstant(Instant.ofEpochSecond(dtNode.asInt()), TimeZone.getDefault().toZoneId()));
|
||||
weather.setCalculatedOn(LocalDateTime.ofInstant(Instant.ofEpochSecond(dtNode.asInt()), TimeZone.getDefault().toZoneId()));
|
||||
}
|
||||
|
||||
return weather;
|
||||
|
||||
+4
-4
@@ -87,9 +87,9 @@ public class WeatherUnitTest {
|
||||
public void whenSetRequestedOn_thenValueIsSet() {
|
||||
final Weather weather = Weather.forValue("state", "desc");
|
||||
final LocalDateTime now = LocalDateTime.now();
|
||||
weather.setRequestedOn(now);
|
||||
weather.setCalculatedOn(now);
|
||||
|
||||
Assert.assertEquals(now, weather.getRequestedOn());
|
||||
Assert.assertEquals(now, weather.getCalculatedOn());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -244,11 +244,11 @@ public class WeatherUnitTest {
|
||||
Assert.assertTrue(one.equals(two));
|
||||
|
||||
final LocalDateTime now = LocalDateTime.now();
|
||||
one.setRequestedOn(now);
|
||||
one.setCalculatedOn(now);
|
||||
|
||||
Assert.assertFalse(one.equals(two));
|
||||
|
||||
two.setRequestedOn(now);
|
||||
two.setCalculatedOn(now);
|
||||
|
||||
Assert.assertTrue(one.equals(two));
|
||||
|
||||
|
||||
+3
-3
@@ -55,7 +55,7 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
Assert.assertNotNull(weather);
|
||||
Assert.assertNotNull(weather.getState());
|
||||
Assert.assertNotNull(weather.getDescription());
|
||||
Assert.assertNotNull(weather.getRequestedOn());
|
||||
Assert.assertNotNull(weather.getCalculatedOn());
|
||||
Assert.assertNotNull(weather.getTemperature());
|
||||
Assert.assertNotNull(weather.getLocation());
|
||||
Assert.assertNotNull(weather.getAtmosphericPressure());
|
||||
@@ -95,7 +95,7 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
Assert.assertNotNull(weather);
|
||||
Assert.assertNotNull(weather.getState());
|
||||
Assert.assertNotNull(weather.getDescription());
|
||||
Assert.assertNotNull(weather.getRequestedOn());
|
||||
Assert.assertNotNull(weather.getCalculatedOn());
|
||||
Assert.assertNotNull(weather.getTemperature());
|
||||
Assert.assertNotNull(weather.getLocation());
|
||||
Assert.assertNotNull(weather.getAtmosphericPressure());
|
||||
@@ -150,7 +150,7 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
Assert.assertNotNull(weather);
|
||||
Assert.assertNotNull(weather.getState());
|
||||
Assert.assertNotNull(weather.getDescription());
|
||||
Assert.assertNotNull(weather.getRequestedOn());
|
||||
Assert.assertNotNull(weather.getCalculatedOn());
|
||||
Assert.assertNotNull(weather.getTemperature());
|
||||
Assert.assertNotNull(weather.getLocation());
|
||||
Assert.assertNotNull(weather.getAtmosphericPressure());
|
||||
|
||||
+7
-7
@@ -51,7 +51,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
Assert.assertNotNull(weather);
|
||||
Assert.assertNotNull(weather.getState());
|
||||
Assert.assertNotNull(weather.getDescription());
|
||||
Assert.assertNotNull(weather.getRequestedOn());
|
||||
Assert.assertNotNull(weather.getCalculatedOn());
|
||||
Assert.assertNotNull(weather.getTemperature());
|
||||
Assert.assertNotNull(weather.getLocation());
|
||||
Assert.assertNotNull(weather.getAtmosphericPressure());
|
||||
@@ -116,7 +116,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
Assert.assertNotNull(weather);
|
||||
Assert.assertNotNull(weather.getState());
|
||||
Assert.assertNotNull(weather.getDescription());
|
||||
Assert.assertNotNull(weather.getRequestedOn());
|
||||
Assert.assertNotNull(weather.getCalculatedOn());
|
||||
Assert.assertNotNull(weather.getTemperature());
|
||||
Assert.assertNotNull(weather.getLocation());
|
||||
Assert.assertNotNull(weather.getAtmosphericPressure());
|
||||
@@ -181,7 +181,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
Assert.assertNotNull(weather);
|
||||
Assert.assertNotNull(weather.getState());
|
||||
Assert.assertNotNull(weather.getDescription());
|
||||
Assert.assertNotNull(weather.getRequestedOn());
|
||||
Assert.assertNotNull(weather.getCalculatedOn());
|
||||
Assert.assertNotNull(weather.getTemperature());
|
||||
Assert.assertNotNull(weather.getLocation());
|
||||
Assert.assertNotNull(weather.getAtmosphericPressure());
|
||||
@@ -245,7 +245,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
Assert.assertNotNull(weather);
|
||||
Assert.assertNotNull(weather.getState());
|
||||
Assert.assertNotNull(weather.getDescription());
|
||||
Assert.assertNotNull(weather.getRequestedOn());
|
||||
Assert.assertNotNull(weather.getCalculatedOn());
|
||||
Assert.assertNotNull(weather.getTemperature());
|
||||
Assert.assertNotNull(weather.getLocation());
|
||||
Assert.assertNotNull(weather.getAtmosphericPressure());
|
||||
@@ -306,7 +306,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
Assert.assertNotNull(weather);
|
||||
Assert.assertNotNull(weather.getState());
|
||||
Assert.assertNotNull(weather.getDescription());
|
||||
Assert.assertNotNull(weather.getRequestedOn());
|
||||
Assert.assertNotNull(weather.getCalculatedOn());
|
||||
Assert.assertNotNull(weather.getTemperature());
|
||||
Assert.assertNotNull(weather.getLocation());
|
||||
Assert.assertNotNull(weather.getAtmosphericPressure());
|
||||
@@ -368,7 +368,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
Assert.assertNotNull(weather);
|
||||
Assert.assertNotNull(weather.getState());
|
||||
Assert.assertNotNull(weather.getDescription());
|
||||
Assert.assertNotNull(weather.getRequestedOn());
|
||||
Assert.assertNotNull(weather.getCalculatedOn());
|
||||
Assert.assertNotNull(weather.getTemperature());
|
||||
Assert.assertNotNull(weather.getLocation());
|
||||
Assert.assertNotNull(weather.getAtmosphericPressure());
|
||||
@@ -433,7 +433,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
Assert.assertNotNull(weather);
|
||||
Assert.assertNotNull(weather.getState());
|
||||
Assert.assertNotNull(weather.getDescription());
|
||||
Assert.assertNotNull(weather.getRequestedOn());
|
||||
Assert.assertNotNull(weather.getCalculatedOn());
|
||||
Assert.assertNotNull(weather.getTemperature());
|
||||
Assert.assertNotNull(weather.getLocation());
|
||||
Assert.assertNotNull(weather.getAtmosphericPressure());
|
||||
|
||||
Reference in New Issue
Block a user