From ea380ac2140d93334e0fac1f61d99012d49e2329 Mon Sep 17 00:00:00 2001 From: Puls Date: Thu, 11 Jan 2018 22:13:03 +0100 Subject: [PATCH] make latitude and longiutude also serializable --- .../darksky/forecast/model/Latitude.java | 43 ++++++++++--------- .../darksky/forecast/model/Longitude.java | 43 ++++++++++--------- 2 files changed, 44 insertions(+), 42 deletions(-) diff --git a/darksky-forecast-api/src/main/java/tk/plogitech/darksky/forecast/model/Latitude.java b/darksky-forecast-api/src/main/java/tk/plogitech/darksky/forecast/model/Latitude.java index 336abd9..3fa74d0 100644 --- a/darksky-forecast-api/src/main/java/tk/plogitech/darksky/forecast/model/Latitude.java +++ b/darksky-forecast-api/src/main/java/tk/plogitech/darksky/forecast/model/Latitude.java @@ -23,6 +23,7 @@ */ package tk.plogitech.darksky.forecast.model; +import java.io.Serializable; import java.util.Objects; import static tk.plogitech.darksky.forecast.util.Assert.notNull; @@ -31,7 +32,7 @@ * * @author Puls */ -public class Latitude { +public class Latitude implements Serializable { private final Double value; @@ -39,40 +40,40 @@ public class Latitude { * @param value The latitude of a location (in decimal degrees). Positive is north, negative is south. */ public Latitude(Double value) { - notNull("The Latitude value cannot be null.", value); - if (value < -90 || value > 90) { - throw new IllegalArgumentException("Latitude must be between -90 and 90. Latitude value invalid: " + value); - } + notNull("The Latitude value cannot be null.", value); + if (value < -90 || value > 90) { + throw new IllegalArgumentException("Latitude must be between -90 and 90. Latitude value invalid: " + value); + } - this.value = value; + this.value = value; } /** * @return The latitude of a location (in decimal degrees). Positive is north, negative is south. */ public Double value() { - return value; + return value; } @Override public int hashCode() { - int hash = 3; - hash = 17 * hash + Objects.hashCode(this.value); - return hash; + int hash = 3; + hash = 17 * hash + Objects.hashCode(this.value); + return hash; } @Override public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final Latitude other = (Latitude) obj; - return Objects.equals(this.value, other.value); + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Latitude other = (Latitude) obj; + return Objects.equals(this.value, other.value); } } diff --git a/darksky-forecast-api/src/main/java/tk/plogitech/darksky/forecast/model/Longitude.java b/darksky-forecast-api/src/main/java/tk/plogitech/darksky/forecast/model/Longitude.java index e135628..844e47e 100644 --- a/darksky-forecast-api/src/main/java/tk/plogitech/darksky/forecast/model/Longitude.java +++ b/darksky-forecast-api/src/main/java/tk/plogitech/darksky/forecast/model/Longitude.java @@ -23,6 +23,7 @@ */ package tk.plogitech.darksky.forecast.model; +import java.io.Serializable; import java.util.Objects; import static tk.plogitech.darksky.forecast.util.Assert.notNull; @@ -31,7 +32,7 @@ * * @author Puls */ -public class Longitude { +public class Longitude implements Serializable { private final Double value; @@ -39,40 +40,40 @@ public class Longitude { * @param value The longitude of a location (in decimal degrees). Positive is east, negative is west. */ public Longitude(Double value) { - notNull("The Longitude value cannot be null.", value); - if (value < -180 || value > 180) { - throw new IllegalArgumentException("Longitude must be between -180 and 180. Latitude value invalid: " + value); - } + notNull("The Longitude value cannot be null.", value); + if (value < -180 || value > 180) { + throw new IllegalArgumentException("Longitude must be between -180 and 180. Latitude value invalid: " + value); + } - this.value = value; + this.value = value; } /** * @return The longitude of a location (in decimal degrees). Positive is east, negative is west. */ public Double value() { - return value; + return value; } @Override public int hashCode() { - int hash = 7; - hash = 53 * hash + Objects.hashCode(this.value); - return hash; + int hash = 7; + hash = 53 * hash + Objects.hashCode(this.value); + return hash; } @Override public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final Longitude other = (Longitude) obj; - return Objects.equals(this.value, other.value); + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Longitude other = (Longitude) obj; + return Objects.equals(this.value, other.value); } }