[vlma-devel] commit: Equal objects must have the same hashCode. (Adrien Grand )

git version control git at videolan.org
Tue Aug 5 23:30:38 CEST 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Tue Aug  5 21:16:43 2008 +0200| [4f9d3d838b1d7b9ff0714b55e93b8ae0b659453a] | committer: Adrien Grand 

Equal objects must have the same hashCode.

> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=4f9d3d838b1d7b9ff0714b55e93b8ae0b659453a
---

 .../main/java/org/videolan/vlma/model/Order.java   |    5 +++++
 .../org/videolan/vlma/model/media/Program.java     |    9 +++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/vlma-api/src/main/java/org/videolan/vlma/model/Order.java b/vlma-api/src/main/java/org/videolan/vlma/model/Order.java
index b946bec..7471758 100644
--- a/vlma-api/src/main/java/org/videolan/vlma/model/Order.java
+++ b/vlma-api/src/main/java/org/videolan/vlma/model/Order.java
@@ -81,4 +81,9 @@ public class Order {
         }
         return false;
     }
+
+    @Override
+    public int hashCode() {
+        return adapter.hashCode() + medias.hashCode();
+    }
 }
diff --git a/vlma-api/src/main/java/org/videolan/vlma/model/media/Program.java b/vlma-api/src/main/java/org/videolan/vlma/model/media/Program.java
index 8b0ae85..0eb96a1 100644
--- a/vlma-api/src/main/java/org/videolan/vlma/model/media/Program.java
+++ b/vlma-api/src/main/java/org/videolan/vlma/model/media/Program.java
@@ -169,6 +169,15 @@ public class Program implements Serializable {
     }
 
     @Override
+    public boolean equals(Object other) {
+        if (other == null || !(other instanceof Program))
+            return false;
+        Program p = (Program) other;
+        return this.getSapGroup().equals(p.getSapGroup())
+                && this.getSapName().equals(p.getSapName());
+    }
+
+    @Override
     public int hashCode() {
         return sapGroup.hashCode() + sapName.hashCode();
     }



More information about the vlma-devel mailing list