mirror of
https://github.com/Prominence/openweathermap-java-api.git
synced 2026-01-10 11:56:44 +03:00
Rechecked weather API response mapping. Refactoring.
This commit is contained in:
parent
f7741e1df6
commit
5d6b8c4d97
@ -49,7 +49,7 @@ public class OpenWeatherMapClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// * Forecast: hourly, daily
|
// * Forecast: hourly, daily. Probably better to cover all free-plan functionality?
|
||||||
// * Air Pollution
|
// * Air Pollution
|
||||||
// * Ultraviolet index
|
// * Ultraviolet index
|
||||||
// DOCS
|
// DOCS
|
||||||
|
|||||||
@ -25,7 +25,6 @@ package com.github.prominence.openweathermap.api.model.forecast;
|
|||||||
import com.github.prominence.openweathermap.api.model.Clouds;
|
import com.github.prominence.openweathermap.api.model.Clouds;
|
||||||
import com.github.prominence.openweathermap.api.model.Humidity;
|
import com.github.prominence.openweathermap.api.model.Humidity;
|
||||||
import com.github.prominence.openweathermap.api.model.Pressure;
|
import com.github.prominence.openweathermap.api.model.Pressure;
|
||||||
import com.github.prominence.openweathermap.api.model.Wind;
|
|
||||||
import com.github.prominence.openweathermap.api.model.DayTime;
|
import com.github.prominence.openweathermap.api.model.DayTime;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|||||||
@ -0,0 +1,158 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.model.forecast;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Wind.
|
||||||
|
*/
|
||||||
|
public class Wind {
|
||||||
|
|
||||||
|
private double speed;
|
||||||
|
private Double degrees;
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new Wind.
|
||||||
|
*
|
||||||
|
* @param speed the speed
|
||||||
|
* @param unit the unitSystem
|
||||||
|
*/
|
||||||
|
public Wind(double speed, String unit) {
|
||||||
|
if (speed < 0) {
|
||||||
|
throw new IllegalArgumentException("Wind speed value must be in positive or zero.");
|
||||||
|
}
|
||||||
|
if (unit == null) {
|
||||||
|
throw new IllegalArgumentException("Unit must be set.");
|
||||||
|
}
|
||||||
|
this.speed = speed;
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets speed.
|
||||||
|
*
|
||||||
|
* @return the speed
|
||||||
|
*/
|
||||||
|
public double getSpeed() {
|
||||||
|
return speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets speed.
|
||||||
|
*
|
||||||
|
* @param speed the speed
|
||||||
|
*/
|
||||||
|
public void setSpeed(double speed) {
|
||||||
|
if (speed < 0) {
|
||||||
|
throw new IllegalArgumentException("Wind speed value must be in positive or zero.");
|
||||||
|
}
|
||||||
|
this.speed = speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets degrees.
|
||||||
|
*
|
||||||
|
* @return the degrees
|
||||||
|
*/
|
||||||
|
public Double getDegrees() {
|
||||||
|
return degrees;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets degrees.
|
||||||
|
*
|
||||||
|
* @param degrees the degrees
|
||||||
|
*/
|
||||||
|
public void setDegrees(double degrees) {
|
||||||
|
if (degrees < 0 || degrees > 360) {
|
||||||
|
throw new IllegalArgumentException("Wind direction value must be in [0, 360] range.");
|
||||||
|
}
|
||||||
|
this.degrees = degrees;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets unitSystem.
|
||||||
|
*
|
||||||
|
* @return the unitSystem
|
||||||
|
*/
|
||||||
|
public String getUnit() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets unitSystem.
|
||||||
|
*
|
||||||
|
* @param unit the unitSystem
|
||||||
|
*/
|
||||||
|
public void setUnit(String unit) {
|
||||||
|
if (unit == null) {
|
||||||
|
throw new IllegalArgumentException("Unit must be set.");
|
||||||
|
}
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (!(o instanceof Wind)) return false;
|
||||||
|
Wind wind = (Wind) o;
|
||||||
|
return Double.compare(wind.speed, speed) == 0 &&
|
||||||
|
Objects.equals(degrees, wind.degrees) &&
|
||||||
|
Objects.equals(unit, wind.unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(speed, degrees, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Wind speed: " + speed + " " + unit +
|
||||||
|
", degrees: " + degrees;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -20,7 +20,29 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.github.prominence.openweathermap.api.model;
|
/*
|
||||||
|
* 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.model.weather;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -20,7 +20,29 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.github.prominence.openweathermap.api.model;
|
/*
|
||||||
|
* 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.model.weather;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -20,7 +20,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.github.prominence.openweathermap.api.model;
|
package com.github.prominence.openweathermap.api.model.weather;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -29,6 +29,7 @@ public class Temperature {
|
|||||||
private double value;
|
private double value;
|
||||||
private Double maxTemperature;
|
private Double maxTemperature;
|
||||||
private Double minTemperature;
|
private Double minTemperature;
|
||||||
|
private Double feelsLike;
|
||||||
private String unit;
|
private String unit;
|
||||||
|
|
||||||
public Temperature(double value, String unit) {
|
public Temperature(double value, String unit) {
|
||||||
@ -63,6 +64,14 @@ public class Temperature {
|
|||||||
this.minTemperature = minTemperature;
|
this.minTemperature = minTemperature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Double getFeelsLike() {
|
||||||
|
return feelsLike;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFeelsLike(Double feelsLike) {
|
||||||
|
this.feelsLike = feelsLike;
|
||||||
|
}
|
||||||
|
|
||||||
public String getUnit() {
|
public String getUnit() {
|
||||||
return unit;
|
return unit;
|
||||||
}
|
}
|
||||||
@ -82,12 +91,13 @@ public class Temperature {
|
|||||||
return Double.compare(that.value, value) == 0 &&
|
return Double.compare(that.value, value) == 0 &&
|
||||||
Objects.equals(maxTemperature, that.maxTemperature) &&
|
Objects.equals(maxTemperature, that.maxTemperature) &&
|
||||||
Objects.equals(minTemperature, that.minTemperature) &&
|
Objects.equals(minTemperature, that.minTemperature) &&
|
||||||
|
Objects.equals(feelsLike, that.feelsLike) &&
|
||||||
Objects.equals(unit, that.unit);
|
Objects.equals(unit, that.unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(value, maxTemperature, minTemperature, unit);
|
return Objects.hash(value, maxTemperature, minTemperature, feelsLike, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -109,6 +119,12 @@ public class Temperature {
|
|||||||
stringBuilder.append(' ');
|
stringBuilder.append(' ');
|
||||||
stringBuilder.append(unit);
|
stringBuilder.append(unit);
|
||||||
}
|
}
|
||||||
|
if (feelsLike != null) {
|
||||||
|
stringBuilder.append(", Feels like: ");
|
||||||
|
stringBuilder.append(feelsLike);
|
||||||
|
stringBuilder.append(' ');
|
||||||
|
stringBuilder.append(unit);
|
||||||
|
}
|
||||||
|
|
||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
@ -20,7 +20,31 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.github.prominence.openweathermap.api.model;
|
/*
|
||||||
|
* 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.model.weather;
|
||||||
|
|
||||||
|
import com.github.prominence.openweathermap.api.model.*;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -30,6 +54,7 @@ public class Weather {
|
|||||||
private String state;
|
private String state;
|
||||||
private String description;
|
private String description;
|
||||||
private String weatherIconUrl;
|
private String weatherIconUrl;
|
||||||
|
|
||||||
private LocalDateTime requestedOn;
|
private LocalDateTime requestedOn;
|
||||||
|
|
||||||
private Temperature temperature;
|
private Temperature temperature;
|
||||||
@ -20,7 +20,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.github.prominence.openweathermap.api.model;
|
package com.github.prominence.openweathermap.api.model.weather;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -31,6 +31,7 @@ public class Wind {
|
|||||||
|
|
||||||
private double speed;
|
private double speed;
|
||||||
private Double degrees;
|
private Double degrees;
|
||||||
|
private Double gust;
|
||||||
private String unit;
|
private String unit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,6 +72,14 @@ public class Wind {
|
|||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Double getGust() {
|
||||||
|
return gust;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGust(double gust) {
|
||||||
|
this.gust = gust;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets degrees.
|
* Gets degrees.
|
||||||
*
|
*
|
||||||
@ -130,7 +139,11 @@ public class Wind {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Wind speed: " + speed + " " + unit +
|
String output = "Wind speed: " + speed + " " + unit +
|
||||||
", degrees: " + degrees;
|
", degrees: " + degrees;
|
||||||
|
if (gust != null) {
|
||||||
|
output += ", Gust: " + gust + " " + unit;
|
||||||
|
}
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,8 +41,8 @@ import java.util.List;
|
|||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Official API response documentation:
|
* Official API response documentation.
|
||||||
* Parameters:
|
* Parameters(but the real response can differ):
|
||||||
* --- cod Internal parameter
|
* --- cod Internal parameter
|
||||||
* --- message Internal parameter
|
* --- message Internal parameter
|
||||||
* --- cnt A number of timestamps returned in the API response
|
* --- cnt A number of timestamps returned in the API response
|
||||||
|
|||||||
@ -24,6 +24,7 @@ package com.github.prominence.openweathermap.api.request.weather;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.github.prominence.openweathermap.api.model.weather.*;
|
||||||
import com.github.prominence.openweathermap.api.request.ResponseMapper;
|
import com.github.prominence.openweathermap.api.request.ResponseMapper;
|
||||||
import com.github.prominence.openweathermap.api.enums.UnitSystem;
|
import com.github.prominence.openweathermap.api.enums.UnitSystem;
|
||||||
import com.github.prominence.openweathermap.api.model.*;
|
import com.github.prominence.openweathermap.api.model.*;
|
||||||
@ -50,6 +51,7 @@ import java.util.TimeZone;
|
|||||||
* --- base Internal parameter
|
* --- base Internal parameter
|
||||||
* --- main
|
* --- main
|
||||||
* |- main.temp Temperature. UnitSystem Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.
|
* |- main.temp Temperature. UnitSystem Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.
|
||||||
|
* |- main.feels_like Temperature. This temperature parameter accounts for the human perception of weather. Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.
|
||||||
* |- main.pressure Atmospheric pressure (on the sea level, if there is no sea_level or grnd_level data), hPa
|
* |- main.pressure Atmospheric pressure (on the sea level, if there is no sea_level or grnd_level data), hPa
|
||||||
* |- main.humidity Humidity, %
|
* |- main.humidity Humidity, %
|
||||||
* |- main.temp_min Minimum temperature at the moment. This is deviation from current temp that is possible for large cities and megalopolises geographically expanded (use these parameter optionally). UnitSystem Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.
|
* |- main.temp_min Minimum temperature at the moment. This is deviation from current temp that is possible for large cities and megalopolises geographically expanded (use these parameter optionally). UnitSystem Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.
|
||||||
@ -59,6 +61,7 @@ import java.util.TimeZone;
|
|||||||
* --- wind
|
* --- wind
|
||||||
* |- wind.speed Wind speed. UnitSystem Default: meter/sec, Metric: meter/sec, Imperial: miles/hour.
|
* |- wind.speed Wind speed. UnitSystem Default: meter/sec, Metric: meter/sec, Imperial: miles/hour.
|
||||||
* |- wind.deg Wind direction, degrees (meteorological)
|
* |- wind.deg Wind direction, degrees (meteorological)
|
||||||
|
* |- wind.gust Wind gust. Unit Default: meter/sec, Metric: meter/sec, Imperial: miles/hour
|
||||||
* --- clouds
|
* --- clouds
|
||||||
* |- clouds.all Cloudiness, %
|
* |- clouds.all Cloudiness, %
|
||||||
* --- rain
|
* --- rain
|
||||||
@ -75,6 +78,7 @@ import java.util.TimeZone;
|
|||||||
* |- sys.country Country code (GB, JP etc.)
|
* |- sys.country Country code (GB, JP etc.)
|
||||||
* |- sys.sunrise Sunrise time, unix, UTC
|
* |- sys.sunrise Sunrise time, unix, UTC
|
||||||
* |- sys.sunset Sunset time, unix, UTC
|
* |- sys.sunset Sunset time, unix, UTC
|
||||||
|
* --- timezone Shift in seconds from UTC
|
||||||
* --- id City ID
|
* --- id City ID
|
||||||
* --- name City name
|
* --- name City name
|
||||||
* --- cod Internal parameter
|
* --- cod Internal parameter
|
||||||
@ -101,23 +105,21 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
|
|||||||
return weather;
|
return weather;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Weather getSingle(JsonNode root) {
|
private Weather getSingle(JsonNode rootNode) {
|
||||||
Weather weather;
|
JsonNode weatherState = rootNode.get("weather").get(0);
|
||||||
|
Weather weather = new Weather(weatherState.get("main").asText(), weatherState.get("description").asText());
|
||||||
JsonNode weatherState = root.get("weather").get(0);
|
|
||||||
weather = new Weather(weatherState.get("main").asText(), weatherState.get("description").asText());
|
|
||||||
weather.setWeatherIconUrl("http://openweathermap.org/img/w/" + weatherState.get("icon").asText() + ".png");
|
weather.setWeatherIconUrl("http://openweathermap.org/img/w/" + weatherState.get("icon").asText() + ".png");
|
||||||
|
|
||||||
weather.setTemperature(parseTemperature(root));
|
weather.setTemperature(parseTemperature(rootNode));
|
||||||
weather.setPressure(parsePressure(root));
|
weather.setPressure(parsePressure(rootNode));
|
||||||
weather.setHumidity(parseHumidity(root));
|
weather.setHumidity(parseHumidity(rootNode));
|
||||||
weather.setWind(parseWind(root));
|
weather.setWind(parseWind(rootNode));
|
||||||
weather.setRain(parseRain(root));
|
weather.setRain(parseRain(rootNode));
|
||||||
weather.setSnow(parseSnow(root));
|
weather.setSnow(parseSnow(rootNode));
|
||||||
weather.setClouds(parseClouds(root));
|
weather.setClouds(parseClouds(rootNode));
|
||||||
weather.setLocation(parseLocation(root));
|
weather.setLocation(parseLocation(rootNode));
|
||||||
|
|
||||||
final JsonNode dtNode = root.get("dt");
|
final JsonNode dtNode = rootNode.get("dt");
|
||||||
if (dtNode != null) {
|
if (dtNode != null) {
|
||||||
weather.setRequestedOn(LocalDateTime.ofInstant(Instant.ofEpochSecond(dtNode.asInt()), TimeZone.getDefault().toZoneId()));
|
weather.setRequestedOn(LocalDateTime.ofInstant(Instant.ofEpochSecond(dtNode.asInt()), TimeZone.getDefault().toZoneId()));
|
||||||
}
|
}
|
||||||
@ -140,12 +142,17 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
|
|||||||
return weatherList;
|
return weatherList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Temperature parseTemperature(JsonNode root) {
|
private Temperature parseTemperature(JsonNode rootNode) {
|
||||||
Temperature temperature;
|
Temperature temperature;
|
||||||
final JsonNode mainNode = root.get("main");
|
final JsonNode mainNode = rootNode.get("main");
|
||||||
|
|
||||||
final double tempValue = mainNode.get("temp").asDouble();
|
final double tempValue = mainNode.get("temp").asDouble();
|
||||||
temperature = new Temperature(tempValue, UnitSystem.getTemperatureUnit(unitSystem));
|
temperature = new Temperature(tempValue, UnitSystem.getTemperatureUnit(unitSystem));
|
||||||
|
|
||||||
|
final JsonNode feelsLikeNode = mainNode.get("feels_like");
|
||||||
|
if (feelsLikeNode != null) {
|
||||||
|
temperature.setFeelsLike(feelsLikeNode.asDouble());
|
||||||
|
}
|
||||||
final JsonNode tempMaxNode = mainNode.get("temp_max");
|
final JsonNode tempMaxNode = mainNode.get("temp_max");
|
||||||
if (tempMaxNode != null) {
|
if (tempMaxNode != null) {
|
||||||
temperature.setMaxTemperature(tempMaxNode.asDouble());
|
temperature.setMaxTemperature(tempMaxNode.asDouble());
|
||||||
@ -158,8 +165,8 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
|
|||||||
return temperature;
|
return temperature;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pressure parsePressure(JsonNode root) {
|
private Pressure parsePressure(JsonNode rootNode) {
|
||||||
final JsonNode mainNode = root.get("main");
|
final JsonNode mainNode = rootNode.get("main");
|
||||||
Pressure pressure = new Pressure(mainNode.get("pressure").asDouble());
|
Pressure pressure = new Pressure(mainNode.get("pressure").asDouble());
|
||||||
|
|
||||||
final JsonNode seaLevelNode = mainNode.get("sea_level");
|
final JsonNode seaLevelNode = mainNode.get("sea_level");
|
||||||
@ -174,29 +181,34 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
|
|||||||
return pressure;
|
return pressure;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Humidity parseHumidity(JsonNode root) {
|
private Humidity parseHumidity(JsonNode rootNode) {
|
||||||
final JsonNode mainNode = root.get("main");
|
final JsonNode mainNode = rootNode.get("main");
|
||||||
|
|
||||||
return new Humidity((byte) (mainNode.get("humidity").asInt()));
|
return new Humidity((byte) (mainNode.get("humidity").asInt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Wind parseWind(JsonNode root) {
|
private Wind parseWind(JsonNode rootNode) {
|
||||||
final JsonNode windNode = root.get("wind");
|
final JsonNode windNode = rootNode.get("wind");
|
||||||
double speed = windNode.get("speed").asDouble();
|
double speed = windNode.get("speed").asDouble();
|
||||||
|
|
||||||
Wind wind = new Wind(speed, UnitSystem.getWindUnit(unitSystem));
|
Wind wind = new Wind(speed, UnitSystem.getWindUnit(unitSystem));
|
||||||
|
|
||||||
final JsonNode degNode = windNode.get("deg");
|
final JsonNode degNode = windNode.get("deg");
|
||||||
if (degNode != null) {
|
if (degNode != null) {
|
||||||
wind.setDegrees(degNode.asDouble());
|
wind.setDegrees(degNode.asDouble());
|
||||||
}
|
}
|
||||||
|
final JsonNode gustNode = windNode.get("gust");
|
||||||
|
if (gustNode != null) {
|
||||||
|
wind.setGust(gustNode.asDouble());
|
||||||
|
}
|
||||||
|
|
||||||
return wind;
|
return wind;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Rain parseRain(JsonNode root) {
|
private Rain parseRain(JsonNode rootNode) {
|
||||||
Rain rain = null;
|
Rain rain = null;
|
||||||
|
|
||||||
final JsonNode rainNode = root.get("rain");
|
final JsonNode rainNode = rootNode.get("rain");
|
||||||
if (rainNode != null) {
|
if (rainNode != null) {
|
||||||
rain = new Rain();
|
rain = new Rain();
|
||||||
final JsonNode oneHourNode = rainNode.get("1h");
|
final JsonNode oneHourNode = rainNode.get("1h");
|
||||||
@ -212,10 +224,10 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
|
|||||||
return rain;
|
return rain;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Snow parseSnow(JsonNode root) {
|
private Snow parseSnow(JsonNode rootNode) {
|
||||||
Snow snow = null;
|
Snow snow = null;
|
||||||
|
|
||||||
final JsonNode snowNode = root.get("snow");
|
final JsonNode snowNode = rootNode.get("snow");
|
||||||
|
|
||||||
if (snowNode != null) {
|
if (snowNode != null) {
|
||||||
snow = new Snow();
|
snow = new Snow();
|
||||||
@ -232,10 +244,10 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
|
|||||||
return snow;
|
return snow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Clouds parseClouds(JsonNode root) {
|
private Clouds parseClouds(JsonNode rootNode) {
|
||||||
Clouds clouds = null;
|
Clouds clouds = null;
|
||||||
|
|
||||||
final JsonNode cloudsNode = root.get("clouds");
|
final JsonNode cloudsNode = rootNode.get("clouds");
|
||||||
final JsonNode allValueNode = cloudsNode.get("all");
|
final JsonNode allValueNode = cloudsNode.get("all");
|
||||||
if (allValueNode != null) {
|
if (allValueNode != null) {
|
||||||
clouds = new Clouds((byte) allValueNode.asInt());
|
clouds = new Clouds((byte) allValueNode.asInt());
|
||||||
@ -244,15 +256,15 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
|
|||||||
return clouds;
|
return clouds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Location parseLocation(JsonNode root) {
|
private Location parseLocation(JsonNode rootNode) {
|
||||||
Location location = new Location(root.get("id").asInt(), root.get("name").asText());
|
Location location = new Location(rootNode.get("id").asInt(), rootNode.get("name").asText());
|
||||||
|
|
||||||
final JsonNode timezoneNode = root.get("timezone");
|
final JsonNode timezoneNode = rootNode.get("timezone");
|
||||||
if (timezoneNode != null) {
|
if (timezoneNode != null) {
|
||||||
location.setZoneOffset(ZoneOffset.ofTotalSeconds(timezoneNode.asInt()));
|
location.setZoneOffset(ZoneOffset.ofTotalSeconds(timezoneNode.asInt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
final JsonNode sysNode = root.get("sys");
|
final JsonNode sysNode = rootNode.get("sys");
|
||||||
if (sysNode != null) {
|
if (sysNode != null) {
|
||||||
final JsonNode countryNode = sysNode.get("country");
|
final JsonNode countryNode = sysNode.get("country");
|
||||||
if (countryNode != null) {
|
if (countryNode != null) {
|
||||||
@ -269,21 +281,20 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final JsonNode coordNode = root.get("coord");
|
final JsonNode coordNode = rootNode.get("coord");
|
||||||
if (coordNode != null) {
|
if (coordNode != null) {
|
||||||
JsonNode latitudeNode = coordNode.get("lat");
|
location.setCoordinate(parseCoordinate(coordNode));
|
||||||
if (latitudeNode == null) {
|
|
||||||
latitudeNode = coordNode.get("Lat"); // in multiple request
|
|
||||||
}
|
|
||||||
JsonNode longitudeNode = coordNode.get("lon");
|
|
||||||
if (longitudeNode == null) {
|
|
||||||
longitudeNode = coordNode.get("Lon"); // in multiple request
|
|
||||||
}
|
|
||||||
if (latitudeNode != null && longitudeNode != null) {
|
|
||||||
location.setCoordinate(new Coordinate(latitudeNode.asDouble(), longitudeNode.asDouble()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Coordinate parseCoordinate(JsonNode rootNode) {
|
||||||
|
JsonNode latitudeNode = rootNode.get("lat");
|
||||||
|
JsonNode longitudeNode = rootNode.get("lon");
|
||||||
|
if (latitudeNode != null && longitudeNode != null) {
|
||||||
|
return new Coordinate(latitudeNode.asDouble(), longitudeNode.asDouble());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
package com.github.prominence.openweathermap.api.request.weather.multiple;
|
package com.github.prominence.openweathermap.api.request.weather.multiple;
|
||||||
|
|
||||||
import com.github.prominence.openweathermap.api.model.Weather;
|
import com.github.prominence.openweathermap.api.model.weather.Weather;
|
||||||
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequestTerminator;
|
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequestTerminator;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ package com.github.prominence.openweathermap.api.request.weather.multiple;
|
|||||||
import com.github.prominence.openweathermap.api.request.RequestUrlBuilder;
|
import com.github.prominence.openweathermap.api.request.RequestUrlBuilder;
|
||||||
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherResponseMapper;
|
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherResponseMapper;
|
||||||
import com.github.prominence.openweathermap.api.enums.UnitSystem;
|
import com.github.prominence.openweathermap.api.enums.UnitSystem;
|
||||||
import com.github.prominence.openweathermap.api.model.Weather;
|
import com.github.prominence.openweathermap.api.model.weather.Weather;
|
||||||
import com.github.prominence.openweathermap.api.utils.RequestUtils;
|
import com.github.prominence.openweathermap.api.utils.RequestUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
package com.github.prominence.openweathermap.api.request.weather.multiple;
|
package com.github.prominence.openweathermap.api.request.weather.multiple;
|
||||||
|
|
||||||
import com.github.prominence.openweathermap.api.model.Weather;
|
import com.github.prominence.openweathermap.api.model.weather.Weather;
|
||||||
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequestTerminator;
|
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequestTerminator;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ package com.github.prominence.openweathermap.api.request.weather.multiple;
|
|||||||
import com.github.prominence.openweathermap.api.request.RequestUrlBuilder;
|
import com.github.prominence.openweathermap.api.request.RequestUrlBuilder;
|
||||||
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherResponseMapper;
|
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherResponseMapper;
|
||||||
import com.github.prominence.openweathermap.api.enums.UnitSystem;
|
import com.github.prominence.openweathermap.api.enums.UnitSystem;
|
||||||
import com.github.prominence.openweathermap.api.model.Weather;
|
import com.github.prominence.openweathermap.api.model.weather.Weather;
|
||||||
import com.github.prominence.openweathermap.api.utils.RequestUtils;
|
import com.github.prominence.openweathermap.api.utils.RequestUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
package com.github.prominence.openweathermap.api.request.weather.single;
|
package com.github.prominence.openweathermap.api.request.weather.single;
|
||||||
|
|
||||||
import com.github.prominence.openweathermap.api.model.Weather;
|
import com.github.prominence.openweathermap.api.model.weather.Weather;
|
||||||
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequestTerminator;
|
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequestTerminator;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ package com.github.prominence.openweathermap.api.request.weather.single;
|
|||||||
import com.github.prominence.openweathermap.api.request.RequestUrlBuilder;
|
import com.github.prominence.openweathermap.api.request.RequestUrlBuilder;
|
||||||
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherResponseMapper;
|
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherResponseMapper;
|
||||||
import com.github.prominence.openweathermap.api.enums.UnitSystem;
|
import com.github.prominence.openweathermap.api.enums.UnitSystem;
|
||||||
import com.github.prominence.openweathermap.api.model.Weather;
|
import com.github.prominence.openweathermap.api.model.weather.Weather;
|
||||||
import com.github.prominence.openweathermap.api.utils.RequestUtils;
|
import com.github.prominence.openweathermap.api.utils.RequestUtils;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
package com.github.prominence.openweathermap.api.request.weather.single;
|
package com.github.prominence.openweathermap.api.request.weather.single;
|
||||||
|
|
||||||
import com.github.prominence.openweathermap.api.model.Weather;
|
import com.github.prominence.openweathermap.api.model.weather.Weather;
|
||||||
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequestTerminator;
|
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequestTerminator;
|
||||||
|
|
||||||
public interface SingleResultCurrentWeatherRequestTerminator extends CurrentWeatherRequestTerminator<Weather, String> {
|
public interface SingleResultCurrentWeatherRequestTerminator extends CurrentWeatherRequestTerminator<Weather, String> {
|
||||||
|
|||||||
@ -25,7 +25,7 @@ package com.github.prominence.openweathermap.api.request.weather.single;
|
|||||||
import com.github.prominence.openweathermap.api.request.RequestUrlBuilder;
|
import com.github.prominence.openweathermap.api.request.RequestUrlBuilder;
|
||||||
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherResponseMapper;
|
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherResponseMapper;
|
||||||
import com.github.prominence.openweathermap.api.enums.UnitSystem;
|
import com.github.prominence.openweathermap.api.enums.UnitSystem;
|
||||||
import com.github.prominence.openweathermap.api.model.Weather;
|
import com.github.prominence.openweathermap.api.model.weather.Weather;
|
||||||
import com.github.prominence.openweathermap.api.utils.RequestUtils;
|
import com.github.prominence.openweathermap.api.utils.RequestUtils;
|
||||||
|
|
||||||
public class SingleResultCurrentWeatherRequestTerminatorImpl implements SingleResultCurrentWeatherRequestTerminator {
|
public class SingleResultCurrentWeatherRequestTerminatorImpl implements SingleResultCurrentWeatherRequestTerminator {
|
||||||
|
|||||||
@ -1,5 +1,28 @@
|
|||||||
package com.github.prominence.openweathermap.api.model;
|
/*
|
||||||
|
* 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.model.weather;
|
||||||
|
|
||||||
|
import com.github.prominence.openweathermap.api.model.Clouds;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class CloudsUnitTest {
|
public class CloudsUnitTest {
|
||||||
@ -1,5 +1,28 @@
|
|||||||
package com.github.prominence.openweathermap.api.model;
|
/*
|
||||||
|
* 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.model.weather;
|
||||||
|
|
||||||
|
import com.github.prominence.openweathermap.api.model.CoordinateRectangle;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class CoordinateRectangleUnitTest {
|
public class CoordinateRectangleUnitTest {
|
||||||
@ -1,5 +1,28 @@
|
|||||||
package com.github.prominence.openweathermap.api.model;
|
/*
|
||||||
|
* 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.model.weather;
|
||||||
|
|
||||||
|
import com.github.prominence.openweathermap.api.model.Coordinate;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class CoordinateUnitTest {
|
public class CoordinateUnitTest {
|
||||||
@ -1,5 +1,28 @@
|
|||||||
package com.github.prominence.openweathermap.api.model;
|
/*
|
||||||
|
* 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.model.weather;
|
||||||
|
|
||||||
|
import com.github.prominence.openweathermap.api.model.Humidity;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class HumidityUnitTest {
|
public class HumidityUnitTest {
|
||||||
@ -1,5 +1,29 @@
|
|||||||
package com.github.prominence.openweathermap.api.model;
|
/*
|
||||||
|
* 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.model.weather;
|
||||||
|
|
||||||
|
import com.github.prominence.openweathermap.api.model.Coordinate;
|
||||||
|
import com.github.prominence.openweathermap.api.model.Location;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -1,5 +1,28 @@
|
|||||||
package com.github.prominence.openweathermap.api.model;
|
/*
|
||||||
|
* 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.model.weather;
|
||||||
|
|
||||||
|
import com.github.prominence.openweathermap.api.model.Pressure;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class PressureUnitTest {
|
public class PressureUnitTest {
|
||||||
@ -1,5 +1,28 @@
|
|||||||
package com.github.prominence.openweathermap.api.model;
|
/*
|
||||||
|
* 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.model.weather;
|
||||||
|
|
||||||
|
import com.github.prominence.openweathermap.api.model.weather.Rain;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class RainUnitTest {
|
public class RainUnitTest {
|
||||||
@ -1,5 +1,28 @@
|
|||||||
package com.github.prominence.openweathermap.api.model;
|
/*
|
||||||
|
* 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.model.weather;
|
||||||
|
|
||||||
|
import com.github.prominence.openweathermap.api.model.weather.Snow;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class SnowUnitTest {
|
public class SnowUnitTest {
|
||||||
@ -1,4 +1,26 @@
|
|||||||
package com.github.prominence.openweathermap.api.model;
|
/*
|
||||||
|
* 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.model.weather;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -1,5 +1,33 @@
|
|||||||
package com.github.prominence.openweathermap.api.model;
|
/*
|
||||||
|
* 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.model.weather;
|
||||||
|
|
||||||
|
import com.github.prominence.openweathermap.api.model.Clouds;
|
||||||
|
import com.github.prominence.openweathermap.api.model.Humidity;
|
||||||
|
import com.github.prominence.openweathermap.api.model.Location;
|
||||||
|
import com.github.prominence.openweathermap.api.model.Pressure;
|
||||||
|
import com.github.prominence.openweathermap.api.model.weather.*;
|
||||||
|
import com.github.prominence.openweathermap.api.model.weather.Temperature;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -1,5 +1,28 @@
|
|||||||
package com.github.prominence.openweathermap.api.model;
|
/*
|
||||||
|
* 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.model.weather;
|
||||||
|
|
||||||
|
import com.github.prominence.openweathermap.api.model.forecast.Wind;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class WindUnitTest {
|
public class WindUnitTest {
|
||||||
@ -29,7 +29,7 @@ import com.github.prominence.openweathermap.api.exception.InvalidAuthTokenExcept
|
|||||||
import com.github.prominence.openweathermap.api.exception.NoDataFoundException;
|
import com.github.prominence.openweathermap.api.exception.NoDataFoundException;
|
||||||
import com.github.prominence.openweathermap.api.model.Coordinate;
|
import com.github.prominence.openweathermap.api.model.Coordinate;
|
||||||
import com.github.prominence.openweathermap.api.model.CoordinateRectangle;
|
import com.github.prominence.openweathermap.api.model.CoordinateRectangle;
|
||||||
import com.github.prominence.openweathermap.api.model.Weather;
|
import com.github.prominence.openweathermap.api.model.weather.Weather;
|
||||||
import com.github.prominence.openweathermap.api.OpenWeatherMapClient;
|
import com.github.prominence.openweathermap.api.OpenWeatherMapClient;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import com.github.prominence.openweathermap.api.enums.UnitSystem;
|
|||||||
import com.github.prominence.openweathermap.api.exception.InvalidAuthTokenException;
|
import com.github.prominence.openweathermap.api.exception.InvalidAuthTokenException;
|
||||||
import com.github.prominence.openweathermap.api.exception.NoDataFoundException;
|
import com.github.prominence.openweathermap.api.exception.NoDataFoundException;
|
||||||
import com.github.prominence.openweathermap.api.model.Coordinate;
|
import com.github.prominence.openweathermap.api.model.Coordinate;
|
||||||
import com.github.prominence.openweathermap.api.model.Weather;
|
import com.github.prominence.openweathermap.api.model.weather.Weather;
|
||||||
import com.github.prominence.openweathermap.api.OpenWeatherMapClient;
|
import com.github.prominence.openweathermap.api.OpenWeatherMapClient;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user