From: Christoph Weitkamp Date: Fri, 18 Feb 2022 07:47:35 +0000 (+0100) Subject: [openweathermap] Code cleanup (#12311) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=bc7e01726f16e3bbb8ff790bb769eea0c51ad673;p=openhab-addons.git [openweathermap] Code cleanup (#12311) Signed-off-by: Christoph Weitkamp --- diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java index 435ff6472e..70e2967f2b 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java @@ -40,8 +40,8 @@ import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonDailyFo import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonHourlyForecastData; import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonUVIndexData; import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonWeatherData; -import org.openhab.binding.openweathermap.internal.dto.onecall.OpenWeatherMapOneCallAPIData; -import org.openhab.binding.openweathermap.internal.dto.onecallhist.OpenWeatherMapOneCallHistAPIData; +import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapOneCallAPIData; +import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapOneCallHistAPIData; import org.openhab.binding.openweathermap.internal.handler.OpenWeatherMapAPIHandler; import org.openhab.core.cache.ByteArrayFileCache; import org.openhab.core.cache.ExpiringCacheMap; diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonAirPollutionData.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonAirPollutionData.java index 0042cb6543..ec83bc9579 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonAirPollutionData.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonAirPollutionData.java @@ -12,6 +12,7 @@ */ package org.openhab.binding.openweathermap.internal.dto; +import org.openhab.binding.openweathermap.internal.dto.airpollution.List; import org.openhab.binding.openweathermap.internal.dto.base.Coord; /** @@ -22,5 +23,5 @@ import org.openhab.binding.openweathermap.internal.dto.base.Coord; */ public class OpenWeatherMapJsonAirPollutionData { public Coord coord; - public java.util.List list; + public java.util.List list; } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonWeatherData.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonWeatherData.java index b388162c23..43c555ae0a 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonWeatherData.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonWeatherData.java @@ -17,8 +17,7 @@ import java.util.List; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.openweathermap.internal.dto.base.Clouds; import org.openhab.binding.openweathermap.internal.dto.base.Coord; -import org.openhab.binding.openweathermap.internal.dto.base.Rain; -import org.openhab.binding.openweathermap.internal.dto.base.Snow; +import org.openhab.binding.openweathermap.internal.dto.base.Precipitation; import org.openhab.binding.openweathermap.internal.dto.base.Weather; import org.openhab.binding.openweathermap.internal.dto.base.Wind; import org.openhab.binding.openweathermap.internal.dto.weather.Main; @@ -38,8 +37,8 @@ public class OpenWeatherMapJsonWeatherData { private @Nullable Integer visibility; private Wind wind; private Clouds clouds; - private @Nullable Rain rain; - private @Nullable Snow snow; + private @Nullable Precipitation rain; + private @Nullable Precipitation snow; private Integer dt; private Sys sys; private Integer id; @@ -102,19 +101,19 @@ public class OpenWeatherMapJsonWeatherData { this.clouds = clouds; } - public @Nullable Rain getRain() { + public @Nullable Precipitation getRain() { return rain; } - public void setRain(Rain rain) { + public void setRain(Precipitation rain) { this.rain = rain; } - public @Nullable Snow getSnow() { + public @Nullable Precipitation getSnow() { return snow; } - public void setSnow(Snow snow) { + public void setSnow(Precipitation snow) { this.snow = snow; } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapOneCallAPIData.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapOneCallAPIData.java new file mode 100644 index 0000000000..2ae2c0a1f7 --- /dev/null +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapOneCallAPIData.java @@ -0,0 +1,113 @@ +/** + * Copyright (c) 2010-2022 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.openweathermap.internal.dto; + +import java.util.List; + +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.openweathermap.internal.dto.onecall.Alert; +import org.openhab.binding.openweathermap.internal.dto.onecall.Current; +import org.openhab.binding.openweathermap.internal.dto.onecall.Daily; +import org.openhab.binding.openweathermap.internal.dto.onecall.Hourly; +import org.openhab.binding.openweathermap.internal.dto.onecall.Minutely; + +import com.google.gson.annotations.SerializedName; + +/** + * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. + * Settings: + * Annotation Style: GSON + * Use primitive types + * Use double numbers + * allow additional properties + * + * @author Wolfgang Klimt - Initial contribution + * @author Christoph Weitkamp - Added weather alerts + */ +public class OpenWeatherMapOneCallAPIData { + private double lat; + private double lon; + private String timezone; + @SerializedName("timezone_offset") + private int timezoneOffset; + private Current current; + private List minutely; + private List hourly; + private List daily; + + public @Nullable List alerts; + + public double getLat() { + return lat; + } + + public void setLat(double lat) { + this.lat = lat; + } + + public double getLon() { + return lon; + } + + public void setLon(double lon) { + this.lon = lon; + } + + public String getTimezone() { + return timezone; + } + + public void setTimezone(String timezone) { + this.timezone = timezone; + } + + public int getTimezoneOffset() { + return timezoneOffset; + } + + public void setTimezoneOffset(int timezoneOffset) { + this.timezoneOffset = timezoneOffset; + } + + public Current getCurrent() { + return current; + } + + public void setCurrent(Current current) { + this.current = current; + } + + public List getMinutely() { + return minutely; + } + + public void setMinutely(List minutely) { + this.minutely = minutely; + } + + public List getHourly() { + return hourly; + } + + public void setHourly(List hourly) { + this.hourly = hourly; + } + + public List getDaily() { + return daily; + } + + public void setDaily(List daily) { + this.daily = daily; + } +} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapOneCallHistAPIData.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapOneCallHistAPIData.java new file mode 100644 index 0000000000..d4676dc7a2 --- /dev/null +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapOneCallHistAPIData.java @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2010-2022 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.openweathermap.internal.dto; + +import java.util.List; + +import org.openhab.binding.openweathermap.internal.dto.onecall.Current; +import org.openhab.binding.openweathermap.internal.dto.onecallhist.Hourly; + +import com.google.gson.annotations.SerializedName; + +/** + * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. + * Settings: + * Annotation Style: GSON + * Use primitive types + * Use double numbers + * allow additional properties + * + * @author Wolfgang Klimt - Initial contribution + */ +public class OpenWeatherMapOneCallHistAPIData { + private double lat; + private double lon; + private String timezone; + @SerializedName("timezone_offset") + private int timezoneOffset; + private Current current; + private List hourly = null; + + public double getLat() { + return lat; + } + + public void setLat(double lat) { + this.lat = lat; + } + + public double getLon() { + return lon; + } + + public void setLon(double lon) { + this.lon = lon; + } + + public String getTimezone() { + return timezone; + } + + public void setTimezone(String timezone) { + this.timezone = timezone; + } + + public int getTimezoneOffset() { + return timezoneOffset; + } + + public void setTimezoneOffset(int timezoneOffset) { + this.timezoneOffset = timezoneOffset; + } + + public Current getCurrent() { + return current; + } + + public void setCurrent(Current current) { + this.current = current; + } + + public List getHourly() { + return hourly; + } + + public void setHourly(List hourly) { + this.hourly = hourly; + } +} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Precipitation.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Precipitation.java new file mode 100644 index 0000000000..f73c3a632e --- /dev/null +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Precipitation.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2010-2022 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.openweathermap.internal.dto.base; + +import org.eclipse.jdt.annotation.Nullable; + +import com.google.gson.annotations.SerializedName; + +/** + * Generated Plain Old Java Objects class for {@link Precipitation} from JSON. + * + * @author Christoph Weitkamp - Initial contribution + */ +public class Precipitation { + @SerializedName("1h") + private @Nullable Double oneHour; + @SerializedName("3h") + private @Nullable Double threeHours; + + public @Nullable Double get1h() { + return oneHour; + } + + public void set1h(Double oneHour) { + this.oneHour = oneHour; + } + + public @Nullable Double get3h() { + return threeHours; + } + + public void set3h(Double threeHours) { + this.threeHours = threeHours; + } + + public Double getVolume() { + return oneHour != null ? oneHour : threeHours != null ? threeHours / 3 : 0; + } +} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Rain.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Rain.java deleted file mode 100644 index da93b32171..0000000000 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Rain.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2010-2022 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.openweathermap.internal.dto.base; - -import org.eclipse.jdt.annotation.Nullable; - -import com.google.gson.annotations.SerializedName; - -/** - * Generated Plain Old Java Objects class for {@link Rain} from JSON. - * - * @author Christoph Weitkamp - Initial contribution - */ -public class Rain { - @SerializedName("1h") - private @Nullable Double oneHour; - @SerializedName("3h") - private @Nullable Double threeHours; - - public @Nullable Double get1h() { - return oneHour; - } - - public void set1h(Double oneHour) { - this.oneHour = oneHour; - } - - public @Nullable Double get3h() { - return threeHours; - } - - public void set3h(Double threeHours) { - this.threeHours = threeHours; - } - - public Double getVolume() { - return oneHour != null ? oneHour : threeHours != null ? threeHours / 3 : 0; - } -} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Snow.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Snow.java deleted file mode 100644 index ea83ec071d..0000000000 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Snow.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2010-2022 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.openweathermap.internal.dto.base; - -import org.eclipse.jdt.annotation.Nullable; - -import com.google.gson.annotations.SerializedName; - -/** - * Generated Plain Old Java Objects class for {@link Snow} from JSON. - * - * @author Christoph Weitkamp - Initial contribution - */ -public class Snow { - @SerializedName("1h") - private @Nullable Double oneHour; - @SerializedName("3h") - private @Nullable Double threeHours; - - public @Nullable Double get1h() { - return oneHour; - } - - public void set1h(Double oneHour) { - this.oneHour = oneHour; - } - - public @Nullable Double get3h() { - return threeHours; - } - - public void set3h(Double threeHours) { - this.threeHours = threeHours; - } - - public Double getVolume() { - return oneHour != null ? oneHour : threeHours != null ? threeHours / 3 : 0; - } -} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/List.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/List.java index a68af62f31..94883fce4e 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/List.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/List.java @@ -72,11 +72,11 @@ public class List { this.temp = temp; } - public @Nullable FeelsLikeTemp getFeelsLikeTemp() { + public @Nullable FeelsLikeTemp getFeelsLike() { return feelsLikeTemp; } - public void setFeelsLikeTemp(FeelsLikeTemp feelsLikeTemp) { + public void setFeelsLike(FeelsLikeTemp feelsLikeTemp) { this.feelsLikeTemp = feelsLikeTemp; } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/List.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/List.java index 2e477de40e..cc6702a586 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/List.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/List.java @@ -14,8 +14,7 @@ package org.openhab.binding.openweathermap.internal.dto.forecast.hourly; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.openweathermap.internal.dto.base.Clouds; -import org.openhab.binding.openweathermap.internal.dto.base.Rain; -import org.openhab.binding.openweathermap.internal.dto.base.Snow; +import org.openhab.binding.openweathermap.internal.dto.base.Precipitation; import org.openhab.binding.openweathermap.internal.dto.base.Weather; import org.openhab.binding.openweathermap.internal.dto.base.Wind; import org.openhab.binding.openweathermap.internal.dto.weather.Main; @@ -33,8 +32,8 @@ public class List { private java.util.List weather; private Clouds clouds; private Wind wind; - private @Nullable Rain rain; - private @Nullable Snow snow; + private @Nullable Precipitation rain; + private @Nullable Precipitation snow; private Sys sys; @SerializedName("dt_txt") private String dtTxt; @@ -79,19 +78,19 @@ public class List { this.wind = wind; } - public @Nullable Rain getRain() { + public @Nullable Precipitation getRain() { return rain; } - public void setRain(Rain rain) { + public void setRain(Precipitation rain) { this.rain = rain; } - public @Nullable Snow getSnow() { + public @Nullable Precipitation getSnow() { return snow; } - public void setSnow(Snow snow) { + public void setSnow(Precipitation snow) { this.snow = snow; } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Current.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Current.java index 421d8054f7..13c9f9a1ac 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Current.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Current.java @@ -14,7 +14,6 @@ package org.openhab.binding.openweathermap.internal.dto.onecall; import java.util.List; -import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; /** @@ -28,58 +27,28 @@ import com.google.gson.annotations.SerializedName; * @author Wolfgang Klimt - Initial contribution */ public class Current { - - @SerializedName("dt") - @Expose private int dt; - @SerializedName("sunrise") - @Expose private int sunrise; - @SerializedName("sunset") - @Expose private int sunset; - @SerializedName("temp") - @Expose private double temp; @SerializedName("feels_like") - @Expose private double feelsLike; - @SerializedName("pressure") - @Expose private int pressure; - @SerializedName("humidity") - @Expose private int humidity; @SerializedName("dew_point") - @Expose private double dewPoint; - @SerializedName("uvi") - @Expose private double uvi; - @SerializedName("clouds") - @Expose private int clouds; - @SerializedName("visibility") - @Expose private int visibility; @SerializedName("wind_speed") - @Expose private double windSpeed; @SerializedName("wind_deg") - @Expose private int windDeg; @SerializedName("wind_gust") - @Expose private double windGust; - @SerializedName("weather") - @Expose private List weather = null; - @SerializedName("rain") - @Expose - private Rain rain; - @SerializedName("snow") - @Expose - private Snow snow; + private Precipitation rain; + private Precipitation snow; public int getDt() { return dt; @@ -201,19 +170,19 @@ public class Current { this.weather = weather; } - public Rain getRain() { + public Precipitation getRain() { return rain; } - public void setRain(Rain rain) { + public void setRain(Precipitation rain) { this.rain = rain; } - public Snow getSnow() { + public Precipitation getSnow() { return snow; } - public void setSnow(Snow snow) { + public void setSnow(Precipitation snow) { this.snow = snow; } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Daily.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Daily.java index c484c42101..64497ddef0 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Daily.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Daily.java @@ -14,7 +14,9 @@ package org.openhab.binding.openweathermap.internal.dto.onecall; import java.util.List; -import com.google.gson.annotations.Expose; +import org.openhab.binding.openweathermap.internal.dto.forecast.daily.FeelsLikeTemp; +import org.openhab.binding.openweathermap.internal.dto.forecast.daily.Temp; + import com.google.gson.annotations.SerializedName; /** @@ -28,60 +30,28 @@ import com.google.gson.annotations.SerializedName; * @author Wolfgang Klimt - Initial contribution */ public class Daily { - - @SerializedName("dt") - @Expose private int dt; - @SerializedName("sunrise") - @Expose private int sunrise; - @SerializedName("sunset") - @Expose private int sunset; - @SerializedName("temp") - @Expose private Temp temp; @SerializedName("feels_like") - @Expose - private FeelsLike feelsLike; - @SerializedName("pressure") - @Expose + private FeelsLikeTemp feelsLikeTemp; private int pressure; - @SerializedName("humidity") - @Expose private int humidity; @SerializedName("dew_point") - @Expose private double dewPoint; @SerializedName("wind_speed") - @Expose private double windSpeed; @SerializedName("wind_deg") - @Expose private int windDeg; @SerializedName("wind_gust") - @Expose private double windGust; - @SerializedName("weather") - @Expose private List weather = null; - @SerializedName("clouds") - @Expose private int clouds; - @SerializedName("pop") - @Expose private double pop; - @SerializedName("visibility") - @Expose private int visibility; - @SerializedName("rain") - @Expose private double rain; - @SerializedName("snow") - @Expose private double snow; - @SerializedName("uvi") - @Expose private double uvi; public int getDt() { @@ -116,12 +86,12 @@ public class Daily { this.temp = temp; } - public FeelsLike getFeelsLike() { - return feelsLike; + public FeelsLikeTemp getFeelsLike() { + return feelsLikeTemp; } - public void setFeelsLike(FeelsLike feelsLike) { - this.feelsLike = feelsLike; + public void setFeelsLike(FeelsLikeTemp feelsLikeTemp) { + this.feelsLikeTemp = feelsLikeTemp; } public int getPressure() { diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/FeelsLike.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/FeelsLike.java deleted file mode 100644 index 25964f5121..0000000000 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/FeelsLike.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2010-2022 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.openweathermap.internal.dto.onecall; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -/** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties - * - * @author Wolfgang Klimt - Initial contribution - */ -public class FeelsLike { - - @SerializedName("day") - @Expose - private double day; - @SerializedName("night") - @Expose - private double night; - @SerializedName("eve") - @Expose - private double eve; - @SerializedName("morn") - @Expose - private double morn; - - public double getDay() { - return day; - } - - public void setDay(double day) { - this.day = day; - } - - public double getNight() { - return night; - } - - public void setNight(double night) { - this.night = night; - } - - public double getEve() { - return eve; - } - - public void setEve(double eve) { - this.eve = eve; - } - - public double getMorn() { - return morn; - } - - public void setMorn(double morn) { - this.morn = morn; - } -} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Hourly.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Hourly.java index 384dd25584..4ae26900fb 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Hourly.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Hourly.java @@ -14,7 +14,6 @@ package org.openhab.binding.openweathermap.internal.dto.onecall; import java.util.List; -import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; /** @@ -28,52 +27,26 @@ import com.google.gson.annotations.SerializedName; * @author Wolfgang Klimt - Initial contribution */ public class Hourly { - - @SerializedName("dt") - @Expose private int dt; - @SerializedName("temp") - @Expose private double temp; @SerializedName("feels_like") - @Expose private double feelsLike; - @SerializedName("pressure") - @Expose private int pressure; - @SerializedName("humidity") - @Expose private int humidity; @SerializedName("dew_point") - @Expose private double dewPoint; - @SerializedName("clouds") - @Expose private int clouds; - @SerializedName("visibility") - @Expose private int visibility; @SerializedName("wind_speed") - @Expose private double windSpeed; @SerializedName("wind_deg") - @Expose private int windDeg; @SerializedName("wind_gust") - @Expose private double windGust; - @SerializedName("weather") - @Expose private List weather = null; - @SerializedName("pop") - @Expose private double pop; - @SerializedName("rain") - @Expose - private Rain rain; - @SerializedName("snow") - @Expose - private Snow snow; + private Precipitation rain; + private Precipitation snow; public int getDt() { return dt; @@ -179,19 +152,19 @@ public class Hourly { this.pop = pop; } - public Rain getRain() { + public Precipitation getRain() { return rain; } - public void setRain(Rain rain) { + public void setRain(Precipitation rain) { this.rain = rain; } - public Snow getSnow() { + public Precipitation getSnow() { return snow; } - public void setSnow(Snow snow) { + public void setSnow(Precipitation snow) { this.snow = snow; } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Minutely.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Minutely.java index bce4596831..4be2719649 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Minutely.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Minutely.java @@ -12,9 +12,6 @@ */ package org.openhab.binding.openweathermap.internal.dto.onecall; -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - /** * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. * Settings: @@ -26,12 +23,7 @@ import com.google.gson.annotations.SerializedName; * @author Wolfgang Klimt - Initial contribution */ public class Minutely { - - @SerializedName("dt") - @Expose private int dt; - @SerializedName("precipitation") - @Expose private double precipitation; public int getDt() { diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/OpenWeatherMapOneCallAPIData.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/OpenWeatherMapOneCallAPIData.java deleted file mode 100644 index cafa4131de..0000000000 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/OpenWeatherMapOneCallAPIData.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Copyright (c) 2010-2022 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.openweathermap.internal.dto.onecall; - -import java.util.List; - -import org.eclipse.jdt.annotation.Nullable; - -import com.google.gson.annotations.SerializedName; - -/** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties - * - * @author Wolfgang Klimt - Initial contribution - * @author Christoph Weitkamp - Added weather alerts - */ -public class OpenWeatherMapOneCallAPIData { - - private double lat; - private double lon; - private String timezone; - @SerializedName("timezone_offset") - private int timezoneOffset; - private Current current; - private List minutely; - private List hourly; - private List daily; - - public @Nullable List alerts; - - public double getLat() { - return lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public double getLon() { - return lon; - } - - public void setLon(double lon) { - this.lon = lon; - } - - public String getTimezone() { - return timezone; - } - - public void setTimezone(String timezone) { - this.timezone = timezone; - } - - public int getTimezoneOffset() { - return timezoneOffset; - } - - public void setTimezoneOffset(int timezoneOffset) { - this.timezoneOffset = timezoneOffset; - } - - public Current getCurrent() { - return current; - } - - public void setCurrent(Current current) { - this.current = current; - } - - public List getMinutely() { - return minutely; - } - - public void setMinutely(List minutely) { - this.minutely = minutely; - } - - public List getHourly() { - return hourly; - } - - public void setHourly(List hourly) { - this.hourly = hourly; - } - - public List getDaily() { - return daily; - } - - public void setDaily(List daily) { - this.daily = daily; - } -} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Precipitation.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Precipitation.java new file mode 100644 index 0000000000..52302fde26 --- /dev/null +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Precipitation.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2022 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.openweathermap.internal.dto.onecall; + +import com.google.gson.annotations.SerializedName; + +/** + * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. + * Settings: + * Annotation Style: GSON + * Use primitive types + * Use double numbers + * allow additional properties + * + * @author Wolfgang Klimt - Initial contribution + */ +public class Precipitation { + @SerializedName("1h") + private double oneHour; + + public double get1h() { + return oneHour; + } + + public void set1h(double oneHour) { + this.oneHour = oneHour; + } +} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Rain.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Rain.java deleted file mode 100644 index 5cb56378c6..0000000000 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Rain.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2010-2022 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.openweathermap.internal.dto.onecall; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -/** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties - * - * @author Wolfgang Klimt - Initial contribution - */ -public class Rain { - - @SerializedName("1h") - @Expose - private double _1h; - - public double get1h() { - return _1h; - } - - public void set1h(double _1h) { - this._1h = _1h; - } -} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Snow.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Snow.java deleted file mode 100644 index c27ad9983f..0000000000 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Snow.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2010-2022 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.openweathermap.internal.dto.onecall; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -/** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties - * - * @author Wolfgang Klimt - Initial contribution - */ -public class Snow { - - @SerializedName("1h") - @Expose - private double _1h; - - public double get1h() { - return _1h; - } - - public void set1h(double _1h) { - this._1h = _1h; - } -} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Temp.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Temp.java deleted file mode 100644 index f365f0d18c..0000000000 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Temp.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Copyright (c) 2010-2022 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.openweathermap.internal.dto.onecall; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -/** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties - * - * @author Wolfgang Klimt - Initial contribution - */ -public class Temp { - - @SerializedName("day") - @Expose - private double day; - @SerializedName("min") - @Expose - private double min; - @SerializedName("max") - @Expose - private double max; - @SerializedName("night") - @Expose - private double night; - @SerializedName("eve") - @Expose - private double eve; - @SerializedName("morn") - @Expose - private double morn; - - public double getDay() { - return day; - } - - public void setDay(double day) { - this.day = day; - } - - public double getMin() { - return min; - } - - public void setMin(double min) { - this.min = min; - } - - public double getMax() { - return max; - } - - public void setMax(double max) { - this.max = max; - } - - public double getNight() { - return night; - } - - public void setNight(double night) { - this.night = night; - } - - public double getEve() { - return eve; - } - - public void setEve(double eve) { - this.eve = eve; - } - - public double getMorn() { - return morn; - } - - public void setMorn(double morn) { - this.morn = morn; - } -} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Weather.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Weather.java index 68c1cfa09b..d7b720f3a9 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Weather.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Weather.java @@ -12,9 +12,6 @@ */ package org.openhab.binding.openweathermap.internal.dto.onecall; -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - /** * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. * Settings: @@ -26,18 +23,9 @@ import com.google.gson.annotations.SerializedName; * @author Wolfgang Klimt - Initial contribution */ public class Weather { - - @SerializedName("id") - @Expose private int id; - @SerializedName("main") - @Expose private String main; - @SerializedName("description") - @Expose private String description; - @SerializedName("icon") - @Expose private String icon; public int getId() { diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Current.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Current.java deleted file mode 100644 index d7e505ebc0..0000000000 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Current.java +++ /dev/null @@ -1,219 +0,0 @@ -/** - * Copyright (c) 2010-2022 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.openweathermap.internal.dto.onecallhist; - -import java.util.List; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -/** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties - * - * @author Wolfgang Klimt - Initial contribution - */ -public class Current { - - @SerializedName("dt") - @Expose - private int dt; - @SerializedName("sunrise") - @Expose - private int sunrise; - @SerializedName("sunset") - @Expose - private int sunset; - @SerializedName("temp") - @Expose - private double temp; - @SerializedName("feels_like") - @Expose - private double feelsLike; - @SerializedName("pressure") - @Expose - private int pressure; - @SerializedName("humidity") - @Expose - private int humidity; - @SerializedName("dew_point") - @Expose - private double dewPoint; - @SerializedName("uvi") - @Expose - private double uvi; - @SerializedName("clouds") - @Expose - private int clouds; - @SerializedName("visibility") - @Expose - private int visibility; - @SerializedName("wind_speed") - @Expose - private double windSpeed; - @SerializedName("wind_deg") - @Expose - private int windDeg; - @SerializedName("wind_gust") - @Expose - private double windGust; - @SerializedName("weather") - @Expose - private List weather = null; - @SerializedName("rain") - @Expose - private Rain rain; - @SerializedName("snow") - @Expose - private Snow snow; - - public int getDt() { - return dt; - } - - public void setDt(int dt) { - this.dt = dt; - } - - public int getSunrise() { - return sunrise; - } - - public void setSunrise(int sunrise) { - this.sunrise = sunrise; - } - - public int getSunset() { - return sunset; - } - - public void setSunset(int sunset) { - this.sunset = sunset; - } - - public double getTemp() { - return temp; - } - - public void setTemp(double temp) { - this.temp = temp; - } - - public double getFeelsLike() { - return feelsLike; - } - - public void setFeelsLike(double feelsLike) { - this.feelsLike = feelsLike; - } - - public int getPressure() { - return pressure; - } - - public void setPressure(int pressure) { - this.pressure = pressure; - } - - public int getHumidity() { - return humidity; - } - - public void setHumidity(int humidity) { - this.humidity = humidity; - } - - public double getDewPoint() { - return dewPoint; - } - - public void setDewPoint(double dewPoint) { - this.dewPoint = dewPoint; - } - - public double getUvi() { - return uvi; - } - - public void setUvi(double uvi) { - this.uvi = uvi; - } - - public int getClouds() { - return clouds; - } - - public void setClouds(int clouds) { - this.clouds = clouds; - } - - public int getVisibility() { - return visibility; - } - - public void setVisibility(int visibility) { - this.visibility = visibility; - } - - public double getWindSpeed() { - return windSpeed; - } - - public void setWindSpeed(double windSpeed) { - this.windSpeed = windSpeed; - } - - public int getWindDeg() { - return windDeg; - } - - public void setWindDeg(int windDeg) { - this.windDeg = windDeg; - } - - public double getWindGust() { - return windGust; - } - - public void setWindGust(double windGust) { - this.windGust = windGust; - } - - public List getWeather() { - return weather; - } - - public void setWeather(List weather) { - this.weather = weather; - } - - public Rain getRain() { - return rain; - } - - public void setRain(Rain rain) { - this.rain = rain; - } - - public Snow getSnow() { - return snow; - } - - public void setSnow(Snow snow) { - this.snow = snow; - } -} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Hourly.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Hourly.java index aed23e66dc..5e50bacb21 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Hourly.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Hourly.java @@ -14,7 +14,9 @@ package org.openhab.binding.openweathermap.internal.dto.onecallhist; import java.util.List; -import com.google.gson.annotations.Expose; +import org.openhab.binding.openweathermap.internal.dto.onecall.Precipitation; +import org.openhab.binding.openweathermap.internal.dto.onecall.Weather; + import com.google.gson.annotations.SerializedName; /** @@ -28,49 +30,25 @@ import com.google.gson.annotations.SerializedName; * @author Wolfgang Klimt - Initial contribution */ public class Hourly { - - @SerializedName("dt") - @Expose private int dt; - @SerializedName("temp") - @Expose private double temp; @SerializedName("feels_like") - @Expose private double feelsLike; - @SerializedName("pressure") - @Expose private int pressure; - @SerializedName("humidity") - @Expose private int humidity; @SerializedName("dew_point") - @Expose private double dewPoint; - @SerializedName("clouds") - @Expose private int clouds; - @SerializedName("visibility") - @Expose private int visibility; @SerializedName("wind_speed") - @Expose private double windSpeed; @SerializedName("wind_deg") - @Expose private int windDeg; @SerializedName("wind_gust") - @Expose private double windGust; - @SerializedName("weather") - @Expose private List weather = null; - @SerializedName("rain") - @Expose - private Rain rain; - @SerializedName("snow") - @Expose - private Snow snow; + private Precipitation rain; + private Precipitation snow; public int getDt() { return dt; @@ -168,19 +146,19 @@ public class Hourly { this.weather = weather; } - public Rain getRain() { + public Precipitation getRain() { return rain; } - public void setRain(Rain rain) { + public void setRain(Precipitation rain) { this.rain = rain; } - public Snow getSnow() { + public Precipitation getSnow() { return snow; } - public void setSnow(Snow snow) { + public void setSnow(Precipitation snow) { this.snow = snow; } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/OpenWeatherMapOneCallHistAPIData.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/OpenWeatherMapOneCallHistAPIData.java deleted file mode 100644 index 1840fc4d24..0000000000 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/OpenWeatherMapOneCallHistAPIData.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright (c) 2010-2022 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.openweathermap.internal.dto.onecallhist; - -import java.util.List; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -/** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties - * - * @author Wolfgang Klimt - Initial contribution - */ -public class OpenWeatherMapOneCallHistAPIData { - - @SerializedName("lat") - @Expose - private double lat; - @SerializedName("lon") - @Expose - private double lon; - @SerializedName("timezone") - @Expose - private String timezone; - @SerializedName("timezone_offset") - @Expose - private int timezoneOffset; - @SerializedName("current") - @Expose - private Current current; - @SerializedName("hourly") - @Expose - private List hourly = null; - - public double getLat() { - return lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public double getLon() { - return lon; - } - - public void setLon(double lon) { - this.lon = lon; - } - - public String getTimezone() { - return timezone; - } - - public void setTimezone(String timezone) { - this.timezone = timezone; - } - - public int getTimezoneOffset() { - return timezoneOffset; - } - - public void setTimezoneOffset(int timezoneOffset) { - this.timezoneOffset = timezoneOffset; - } - - public Current getCurrent() { - return current; - } - - public void setCurrent(Current current) { - this.current = current; - } - - public List getHourly() { - return hourly; - } - - public void setHourly(List hourly) { - this.hourly = hourly; - } -} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Rain.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Rain.java deleted file mode 100644 index f29053a280..0000000000 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Rain.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2010-2022 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.openweathermap.internal.dto.onecallhist; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -/** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties - * - * @author Wolfgang Klimt - Initial contribution - */ -public class Rain { - - @SerializedName("1h") - @Expose - private double _1h; - - public double get1h() { - return _1h; - } - - public void set1h(double _1h) { - this._1h = _1h; - } -} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Snow.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Snow.java deleted file mode 100644 index c6243255fe..0000000000 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Snow.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2010-2022 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.openweathermap.internal.dto.onecallhist; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -/** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties - * - * @author Wolfgang Klimt - Initial contribution - */ -public class Snow { - - @SerializedName("1h") - @Expose - private double _1h; - - public double get1h() { - return _1h; - } - - public void set1h(double _1h) { - this._1h = _1h; - } -} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Weather.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Weather.java deleted file mode 100644 index b32a84750d..0000000000 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Weather.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2010-2022 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.openweathermap.internal.dto.onecallhist; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -/** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties - * - * @author Wolfgang Klimt - Initial contribution - */ -public class Weather { - - @SerializedName("id") - @Expose - private int id; - @SerializedName("main") - @Expose - private String main; - @SerializedName("description") - @Expose - private String description; - @SerializedName("icon") - @Expose - private String icon; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getMain() { - return main; - } - - public void setMain(String main) { - this.main = main; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getIcon() { - return icon; - } - - public void setIcon(String icon) { - this.icon = icon; - } -} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapOneCallHandler.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapOneCallHandler.java index 625e458361..7c7611d396 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapOneCallHandler.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapOneCallHandler.java @@ -26,12 +26,11 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.openweathermap.internal.config.OpenWeatherMapOneCallConfiguration; import org.openhab.binding.openweathermap.internal.connection.OpenWeatherMapConnection; +import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapOneCallAPIData; +import org.openhab.binding.openweathermap.internal.dto.forecast.daily.FeelsLikeTemp; +import org.openhab.binding.openweathermap.internal.dto.forecast.daily.Temp; import org.openhab.binding.openweathermap.internal.dto.onecall.Alert; -import org.openhab.binding.openweathermap.internal.dto.onecall.FeelsLike; -import org.openhab.binding.openweathermap.internal.dto.onecall.OpenWeatherMapOneCallAPIData; -import org.openhab.binding.openweathermap.internal.dto.onecall.Rain; -import org.openhab.binding.openweathermap.internal.dto.onecall.Snow; -import org.openhab.binding.openweathermap.internal.dto.onecall.Temp; +import org.openhab.binding.openweathermap.internal.dto.onecall.Precipitation; import org.openhab.core.i18n.CommunicationException; import org.openhab.core.i18n.ConfigurationException; import org.openhab.core.i18n.TimeZoneProvider; @@ -348,11 +347,11 @@ public class OpenWeatherMapOneCallHandler extends AbstractOpenWeatherMapHandler state = getDecimalTypeState(localWeatherData.getCurrent().getUvi()); break; case CHANNEL_RAIN: - Rain rain = localWeatherData.getCurrent().getRain(); + Precipitation rain = localWeatherData.getCurrent().getRain(); state = getQuantityTypeState(rain == null ? 0 : rain.get1h(), MILLI(METRE)); break; case CHANNEL_SNOW: - Snow snow = localWeatherData.getCurrent().getSnow(); + Precipitation snow = localWeatherData.getCurrent().getSnow(); state = getQuantityTypeState(snow == null ? 0 : snow.get1h(), MILLI(METRE)); break; case CHANNEL_VISIBILITY: @@ -487,11 +486,11 @@ public class OpenWeatherMapOneCallHandler extends AbstractOpenWeatherMapHandler state = getQuantityTypeState(forecastData.getPop() * 100.0, PERCENT); break; case CHANNEL_RAIN: - Rain rain = forecastData.getRain(); + Precipitation rain = forecastData.getRain(); state = getQuantityTypeState(rain == null ? 0 : rain.get1h(), MILLI(METRE)); break; case CHANNEL_SNOW: - Snow snow = forecastData.getSnow(); + Precipitation snow = forecastData.getSnow(); state = getQuantityTypeState(snow == null ? 0 : snow.get1h(), MILLI(METRE)); break; default: @@ -527,7 +526,7 @@ public class OpenWeatherMapOneCallHandler extends AbstractOpenWeatherMapHandler .get(count); State state = UnDefType.UNDEF; Temp temp; - FeelsLike feelsLike; + FeelsLikeTemp feelsLike; switch (channelId) { case CHANNEL_TIME_STAMP: state = getDateTimeTypeState(forecastData.getDt()); diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapOneCallHistoryHandler.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapOneCallHistoryHandler.java index ac31e253ae..51d015a971 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapOneCallHistoryHandler.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapOneCallHistoryHandler.java @@ -24,10 +24,9 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.openweathermap.internal.config.OpenWeatherMapOneCallHistoryConfiguration; import org.openhab.binding.openweathermap.internal.connection.OpenWeatherMapConnection; +import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapOneCallHistAPIData; +import org.openhab.binding.openweathermap.internal.dto.onecall.Precipitation; import org.openhab.binding.openweathermap.internal.dto.onecallhist.Hourly; -import org.openhab.binding.openweathermap.internal.dto.onecallhist.OpenWeatherMapOneCallHistAPIData; -import org.openhab.binding.openweathermap.internal.dto.onecallhist.Rain; -import org.openhab.binding.openweathermap.internal.dto.onecallhist.Snow; import org.openhab.core.i18n.CommunicationException; import org.openhab.core.i18n.ConfigurationException; import org.openhab.core.i18n.TimeZoneProvider; @@ -198,11 +197,11 @@ public class OpenWeatherMapOneCallHistoryHandler extends AbstractOpenWeatherMapH state = getDecimalTypeState(localWeatherData.getCurrent().getUvi()); break; case CHANNEL_RAIN: - Rain rain = localWeatherData.getCurrent().getRain(); + Precipitation rain = localWeatherData.getCurrent().getRain(); state = getQuantityTypeState(rain == null ? 0 : rain.get1h(), MILLI(METRE)); break; case CHANNEL_SNOW: - Snow snow = localWeatherData.getCurrent().getSnow(); + Precipitation snow = localWeatherData.getCurrent().getSnow(); state = getQuantityTypeState(snow == null ? 0 : snow.get1h(), MILLI(METRE)); break; case CHANNEL_VISIBILITY: @@ -295,11 +294,11 @@ public class OpenWeatherMapOneCallHistoryHandler extends AbstractOpenWeatherMapH State tempstate = new QuantityType<>(historyData.getVisibility(), METRE).toUnit(KILO(METRE)); state = (tempstate == null ? state : tempstate); case CHANNEL_RAIN: - Rain rain = historyData.getRain(); + Precipitation rain = historyData.getRain(); state = getQuantityTypeState(rain == null ? 0 : rain.get1h(), MILLI(METRE)); break; case CHANNEL_SNOW: - Snow snow = historyData.getSnow(); + Precipitation snow = historyData.getSnow(); state = getQuantityTypeState(snow == null ? 0 : snow.get1h(), MILLI(METRE)); break; default: diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapWeatherAndForecastHandler.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapWeatherAndForecastHandler.java index 6ade3a2d5b..741603f290 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapWeatherAndForecastHandler.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapWeatherAndForecastHandler.java @@ -31,8 +31,7 @@ import org.openhab.binding.openweathermap.internal.connection.OpenWeatherMapConn import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonDailyForecastData; import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonHourlyForecastData; import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonWeatherData; -import org.openhab.binding.openweathermap.internal.dto.base.Rain; -import org.openhab.binding.openweathermap.internal.dto.base.Snow; +import org.openhab.binding.openweathermap.internal.dto.base.Precipitation; import org.openhab.binding.openweathermap.internal.dto.forecast.daily.FeelsLikeTemp; import org.openhab.core.config.core.Configuration; import org.openhab.core.i18n.CommunicationException; @@ -301,11 +300,11 @@ public class OpenWeatherMapWeatherAndForecastHandler extends AbstractOpenWeather state = getQuantityTypeState(localWeatherData.getClouds().getAll(), PERCENT); break; case CHANNEL_RAIN: - Rain rain = localWeatherData.getRain(); + Precipitation rain = localWeatherData.getRain(); state = getQuantityTypeState(rain == null ? 0 : rain.getVolume(), MILLI(METRE)); break; case CHANNEL_SNOW: - Snow snow = localWeatherData.getSnow(); + Precipitation snow = localWeatherData.getSnow(); state = getQuantityTypeState(snow == null ? 0 : snow.getVolume(), MILLI(METRE)); break; case CHANNEL_VISIBILITY: @@ -395,11 +394,11 @@ public class OpenWeatherMapWeatherAndForecastHandler extends AbstractOpenWeather state = getQuantityTypeState(forecastData.getClouds().getAll(), PERCENT); break; case CHANNEL_RAIN: - Rain rain = forecastData.getRain(); + Precipitation rain = forecastData.getRain(); state = getQuantityTypeState(rain == null ? 0 : rain.getVolume(), MILLI(METRE)); break; case CHANNEL_SNOW: - Snow snow = forecastData.getSnow(); + Precipitation snow = forecastData.getSnow(); state = getQuantityTypeState(snow == null ? 0 : snow.getVolume(), MILLI(METRE)); break; } @@ -462,7 +461,7 @@ public class OpenWeatherMapWeatherAndForecastHandler extends AbstractOpenWeather state = getQuantityTypeState(forecastData.getTemp().getMax(), CELSIUS); break; case CHANNEL_APPARENT_TEMPERATURE: - FeelsLikeTemp feelsLikeTemp = forecastData.getFeelsLikeTemp(); + FeelsLikeTemp feelsLikeTemp = forecastData.getFeelsLike(); if (feelsLikeTemp != null) { state = getQuantityTypeState(feelsLikeTemp.getDay(), CELSIUS); }