< prev index next >

modules/base/src/main/java/javafx/util/Pair.java

Print this page
rev 9268 : 8140503: JavaFX "Pair" Hash Code Collisions

@@ -24,10 +24,11 @@
  */
 
 package javafx.util;
 
 import java.io.Serializable;
+import java.util.Objects;
 import javafx.beans.NamedArg;
 
  /**
   * <p>A convenience class to represent name-value pairs.</p>
   * @since JavaFX 2.0

@@ -87,16 +88,11 @@
      *
      * @return hash code for this <code>Pair</code>
      */
     @Override
     public int hashCode() {
-        // name's hashCode is multiplied by an arbitrary prime number (13)
-        // in order to make sure there is a difference in the hashCode between
-        // these two parameters:
-        //  name: a  value: aa
-        //  name: aa value: a
-        return key.hashCode() * 13 + (value == null ? 0 : value.hashCode());
+        return Objects.hash(key, value);
     }
 
      /**
       * <p>Test this <code>Pair</code> for equality with another
       * <code>Object</code>.</p>
< prev index next >