Rechecked weather API response mapping. Refactoring.

This commit is contained in:
Alexey Zinchenko 2021-03-22 23:00:30 +03:00
parent f7741e1df6
commit 5d6b8c4d97
31 changed files with 600 additions and 76 deletions

View File

@ -49,7 +49,7 @@ public class OpenWeatherMapClient {
}
// TODO:
// * Forecast: hourly, daily
// * Forecast: hourly, daily. Probably better to cover all free-plan functionality?
// * Air Pollution
// * Ultraviolet index
// DOCS

View File

@ -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.Humidity;
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 java.time.LocalDateTime;

View File

@ -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;
}
}

View File

@ -20,7 +20,29 @@
* 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;

View File

@ -20,7 +20,29 @@
* 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;

View File

@ -20,7 +20,7 @@
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model;
package com.github.prominence.openweathermap.api.model.weather;
import java.util.Objects;
@ -29,6 +29,7 @@ public class Temperature {
private double value;
private Double maxTemperature;
private Double minTemperature;
private Double feelsLike;
private String unit;
public Temperature(double value, String unit) {
@ -63,6 +64,14 @@ public class Temperature {
this.minTemperature = minTemperature;
}
public Double getFeelsLike() {
return feelsLike;
}
public void setFeelsLike(Double feelsLike) {
this.feelsLike = feelsLike;
}
public String getUnit() {
return unit;
}
@ -82,12 +91,13 @@ public class Temperature {
return Double.compare(that.value, value) == 0 &&
Objects.equals(maxTemperature, that.maxTemperature) &&
Objects.equals(minTemperature, that.minTemperature) &&
Objects.equals(feelsLike, that.feelsLike) &&
Objects.equals(unit, that.unit);
}
@Override
public int hashCode() {
return Objects.hash(value, maxTemperature, minTemperature, unit);
return Objects.hash(value, maxTemperature, minTemperature, feelsLike, unit);
}
@Override
@ -109,6 +119,12 @@ public class Temperature {
stringBuilder.append(' ');
stringBuilder.append(unit);
}
if (feelsLike != null) {
stringBuilder.append(", Feels like: ");
stringBuilder.append(feelsLike);
stringBuilder.append(' ');
stringBuilder.append(unit);
}
return stringBuilder.toString();
}

View File

@ -20,7 +20,31 @@
* 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.util.Objects;
@ -30,6 +54,7 @@ public class Weather {
private String state;
private String description;
private String weatherIconUrl;
private LocalDateTime requestedOn;
private Temperature temperature;

View File

@ -20,7 +20,7 @@
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model;
package com.github.prominence.openweathermap.api.model.weather;
import java.util.Objects;
@ -31,6 +31,7 @@ public class Wind {
private double speed;
private Double degrees;
private Double gust;
private String unit;
/**
@ -71,6 +72,14 @@ public class Wind {
this.speed = speed;
}
public Double getGust() {
return gust;
}
public void setGust(double gust) {
this.gust = gust;
}
/**
* Gets degrees.
*
@ -130,7 +139,11 @@ public class Wind {
@Override
public String toString() {
return "Wind speed: " + speed + " " + unit +
String output = "Wind speed: " + speed + " " + unit +
", degrees: " + degrees;
if (gust != null) {
output += ", Gust: " + gust + " " + unit;
}
return output;
}
}

View File

@ -41,8 +41,8 @@ import java.util.List;
import java.util.TimeZone;
/**
* Official API response documentation:
* Parameters:
* Official API response documentation.
* Parameters(but the real response can differ):
* --- cod Internal parameter
* --- message Internal parameter
* --- cnt A number of timestamps returned in the API response

View File

@ -24,6 +24,7 @@ package com.github.prominence.openweathermap.api.request.weather;
import com.fasterxml.jackson.databind.JsonNode;
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.enums.UnitSystem;
import com.github.prominence.openweathermap.api.model.*;
@ -50,6 +51,7 @@ import java.util.TimeZone;
* --- base Internal parameter
* --- main
* |- 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.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.
@ -59,6 +61,7 @@ import java.util.TimeZone;
* --- wind
* |- wind.speed Wind speed. UnitSystem Default: meter/sec, Metric: meter/sec, Imperial: miles/hour.
* |- wind.deg Wind direction, degrees (meteorological)
* |- wind.gust Wind gust. Unit Default: meter/sec, Metric: meter/sec, Imperial: miles/hour
* --- clouds
* |- clouds.all Cloudiness, %
* --- rain
@ -75,6 +78,7 @@ import java.util.TimeZone;
* |- sys.country Country code (GB, JP etc.)
* |- sys.sunrise Sunrise time, unix, UTC
* |- sys.sunset Sunset time, unix, UTC
* --- timezone Shift in seconds from UTC
* --- id City ID
* --- name City name
* --- cod Internal parameter
@ -101,23 +105,21 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
return weather;
}
private Weather getSingle(JsonNode root) {
Weather weather;
JsonNode weatherState = root.get("weather").get(0);
weather = new Weather(weatherState.get("main").asText(), weatherState.get("description").asText());
private Weather getSingle(JsonNode rootNode) {
JsonNode weatherState = rootNode.get("weather").get(0);
Weather weather = new Weather(weatherState.get("main").asText(), weatherState.get("description").asText());
weather.setWeatherIconUrl("http://openweathermap.org/img/w/" + weatherState.get("icon").asText() + ".png");
weather.setTemperature(parseTemperature(root));
weather.setPressure(parsePressure(root));
weather.setHumidity(parseHumidity(root));
weather.setWind(parseWind(root));
weather.setRain(parseRain(root));
weather.setSnow(parseSnow(root));
weather.setClouds(parseClouds(root));
weather.setLocation(parseLocation(root));
weather.setTemperature(parseTemperature(rootNode));
weather.setPressure(parsePressure(rootNode));
weather.setHumidity(parseHumidity(rootNode));
weather.setWind(parseWind(rootNode));
weather.setRain(parseRain(rootNode));
weather.setSnow(parseSnow(rootNode));
weather.setClouds(parseClouds(rootNode));
weather.setLocation(parseLocation(rootNode));
final JsonNode dtNode = root.get("dt");
final JsonNode dtNode = rootNode.get("dt");
if (dtNode != null) {
weather.setRequestedOn(LocalDateTime.ofInstant(Instant.ofEpochSecond(dtNode.asInt()), TimeZone.getDefault().toZoneId()));
}
@ -140,12 +142,17 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
return weatherList;
}
private Temperature parseTemperature(JsonNode root) {
private Temperature parseTemperature(JsonNode rootNode) {
Temperature temperature;
final JsonNode mainNode = root.get("main");
final JsonNode mainNode = rootNode.get("main");
final double tempValue = mainNode.get("temp").asDouble();
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");
if (tempMaxNode != null) {
temperature.setMaxTemperature(tempMaxNode.asDouble());
@ -158,8 +165,8 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
return temperature;
}
private Pressure parsePressure(JsonNode root) {
final JsonNode mainNode = root.get("main");
private Pressure parsePressure(JsonNode rootNode) {
final JsonNode mainNode = rootNode.get("main");
Pressure pressure = new Pressure(mainNode.get("pressure").asDouble());
final JsonNode seaLevelNode = mainNode.get("sea_level");
@ -174,29 +181,34 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
return pressure;
}
private Humidity parseHumidity(JsonNode root) {
final JsonNode mainNode = root.get("main");
private Humidity parseHumidity(JsonNode rootNode) {
final JsonNode mainNode = rootNode.get("main");
return new Humidity((byte) (mainNode.get("humidity").asInt()));
}
private Wind parseWind(JsonNode root) {
final JsonNode windNode = root.get("wind");
private Wind parseWind(JsonNode rootNode) {
final JsonNode windNode = rootNode.get("wind");
double speed = windNode.get("speed").asDouble();
Wind wind = new Wind(speed, UnitSystem.getWindUnit(unitSystem));
final JsonNode degNode = windNode.get("deg");
if (degNode != null) {
wind.setDegrees(degNode.asDouble());
}
final JsonNode gustNode = windNode.get("gust");
if (gustNode != null) {
wind.setGust(gustNode.asDouble());
}
return wind;
}
private Rain parseRain(JsonNode root) {
private Rain parseRain(JsonNode rootNode) {
Rain rain = null;
final JsonNode rainNode = root.get("rain");
final JsonNode rainNode = rootNode.get("rain");
if (rainNode != null) {
rain = new Rain();
final JsonNode oneHourNode = rainNode.get("1h");
@ -212,10 +224,10 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
return rain;
}
private Snow parseSnow(JsonNode root) {
private Snow parseSnow(JsonNode rootNode) {
Snow snow = null;
final JsonNode snowNode = root.get("snow");
final JsonNode snowNode = rootNode.get("snow");
if (snowNode != null) {
snow = new Snow();
@ -232,10 +244,10 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
return snow;
}
private Clouds parseClouds(JsonNode root) {
private Clouds parseClouds(JsonNode rootNode) {
Clouds clouds = null;
final JsonNode cloudsNode = root.get("clouds");
final JsonNode cloudsNode = rootNode.get("clouds");
final JsonNode allValueNode = cloudsNode.get("all");
if (allValueNode != null) {
clouds = new Clouds((byte) allValueNode.asInt());
@ -244,15 +256,15 @@ public class CurrentWeatherResponseMapper implements ResponseMapper<Weather> {
return clouds;
}
private Location parseLocation(JsonNode root) {
Location location = new Location(root.get("id").asInt(), root.get("name").asText());
private Location parseLocation(JsonNode rootNode) {
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) {
location.setZoneOffset(ZoneOffset.ofTotalSeconds(timezoneNode.asInt()));
}
final JsonNode sysNode = root.get("sys");
final JsonNode sysNode = rootNode.get("sys");
if (sysNode != null) {
final JsonNode countryNode = sysNode.get("country");
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) {
JsonNode latitudeNode = coordNode.get("lat");
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()));
}
location.setCoordinate(parseCoordinate(coordNode));
}
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;
}
}

View File

@ -22,7 +22,7 @@
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 java.util.List;

View File

@ -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.weather.CurrentWeatherResponseMapper;
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 java.util.List;

View File

@ -22,7 +22,7 @@
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 java.util.List;

View File

@ -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.weather.CurrentWeatherResponseMapper;
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 java.util.List;

View File

@ -22,7 +22,7 @@
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 java.util.concurrent.CompletableFuture;

View File

@ -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.weather.CurrentWeatherResponseMapper;
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 java.util.concurrent.CompletableFuture;

View File

@ -22,7 +22,7 @@
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;
public interface SingleResultCurrentWeatherRequestTerminator extends CurrentWeatherRequestTerminator<Weather, String> {

View File

@ -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.weather.CurrentWeatherResponseMapper;
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;
public class SingleResultCurrentWeatherRequestTerminatorImpl implements SingleResultCurrentWeatherRequestTerminator {

View File

@ -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;
public class CloudsUnitTest {

View File

@ -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;
public class CoordinateRectangleUnitTest {

View File

@ -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;
public class CoordinateUnitTest {

View File

@ -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;
public class HumidityUnitTest {

View File

@ -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 java.time.LocalDateTime;

View File

@ -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;
public class PressureUnitTest {

View File

@ -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;
public class RainUnitTest {

View File

@ -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;
public class SnowUnitTest {

View File

@ -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;

View File

@ -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 java.time.LocalDateTime;

View File

@ -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;
public class WindUnitTest {

View File

@ -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.model.Coordinate;
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 org.junit.Test;

View File

@ -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.NoDataFoundException;
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 org.junit.Test;