< prev index next >

src/java.desktop/share/classes/java/awt/image/BandedSampleModel.java

Print this page

        

@@ -840,10 +840,44 @@
             bankIndices[i] = i;
         }
         return bankIndices;
     }
 
-    // Differentiate hash code from other ComponentSampleModel subclasses
+    /**
+     * Tests if the specified {@code Object} is an instance
+     * of {@code BandedSampleModel} and equals this
+     * {@code BandedSampleModel}.
+     * @param obj the {@code Object} to test for equality
+     * @return {@code true} if the specified {@code Object}
+     * is an instance of {@code BandedSampleModel} and equals this
+     * {@code BandedSampleModel}; {@code false} otherwise.
+     */
+    @Override
+    public boolean equals(Object obj) {
+
+        if (!(obj instanceof BandedSampleModel)) {
+            return false;
+        }
+ 
+        BandedSampleModel cm = (BandedSampleModel) obj;
+        if (this == cm) {
+            return true;
+        }
+
+        if (!super.equals(obj)) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Returns the hash code for this BandedSampleModel.
+     *
+     * @return    a hash code for this BandedSampleModel.
+     */
+    @Override
     public int hashCode() {
-        return super.hashCode() ^ 0x2;
+        int hash = 5;
+        hash = 13 * hash + super.hashCode();
+        return hash;
     }
 }
< prev index next >