From ed3ce3ccc5a9455e553d2f1c258f33622502ae23 Mon Sep 17 00:00:00 2001 From: "andreas.schildbach@gmail.com" Date: Sat, 18 Feb 2012 20:27:37 +0000 Subject: [PATCH] fixed equals/hashCode git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@950 0924bc21-9374-b0fa-ee44-9ff1593b38f0 --- src/de/schildbach/pte/dto/Location.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/de/schildbach/pte/dto/Location.java b/src/de/schildbach/pte/dto/Location.java index 62c979ea..be4bd4e6 100644 --- a/src/de/schildbach/pte/dto/Location.java +++ b/src/de/schildbach/pte/dto/Location.java @@ -123,9 +123,11 @@ public final class Location implements Serializable return false; if (this.id != other.id) return false; - if (this.id != 0) // TODO needed? - return true; - return nullSafeEquals(this.name, other.name); + if (this.lat != other.lat || this.lon != other.lon) + return false; + if (this.id == 0 && !nullSafeEquals(this.name, other.name)) // only discriminate by name if no ids are given + return false; + return true; } @Override @@ -136,7 +138,9 @@ public final class Location implements Serializable hashCode *= 29; hashCode += id; hashCode *= 29; - hashCode += nullSafeHashCode(name); + hashCode += lat; + hashCode *= 29; + hashCode += lon; return hashCode; }