Permalink
Browse files

Fixed #367 -- Parameter.equals() always returned false.

  • Loading branch information...
1 parent 17ba207 commit 74e1cfa5810139ade494be8465f4d27918b8615c @okram okram committed Mar 8, 2013
@@ -50,18 +50,19 @@ public boolean equals(Object object) {
if (!otherValue.equals(value))
return false;
}
+ return true;
}
return false;
}
-
+
@Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((key == null) ? 0 : key.hashCode());
- result = prime * result + ((value == null) ? 0 : value.hashCode());
- return result;
- }
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((key == null) ? 0 : key.hashCode());
+ result = prime * result + ((value == null) ? 0 : value.hashCode());
+ return result;
+ }
public String toString() {
return "parameter[" + key + "," + value + "]";
@@ -0,0 +1,30 @@
+package com.tinkerpop.blueprints;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class ParameterTest extends TestCase {
+
+ public void testEquality() {
+ Parameter<String,Long> a = new Parameter<String, Long>("blah",7l);
+ Parameter<String,Long> b = new Parameter<String, Long>("blah",7l);
+
+ assertEquals(a,a);
+ assertEquals(b,b);
+ assertEquals(a,b);
+
+ Parameter<String,Long> c = new Parameter<String, Long>("blah",6l);
+
+ assertNotSame(a,c);
+ assertNotSame(b,c);
+
+ Parameter<String,Long> d = new Parameter<String, Long>("boop",7l);
+
+ assertNotSame(a,d);
+ assertNotSame(b,d);
+ assertNotSame(c,d);
+
+ }
+}

0 comments on commit 74e1cfa

Please sign in to comment.