< prev index next >
src/java.desktop/share/classes/java/awt/image/ComponentColorModel.java
Print this page
@@ -2925,24 +2925,40 @@
raster.getHeight(), x, y,
band);
}
/**
- * Compares this color model with another for equality.
- *
- * @param obj The object to compare with this color model.
- * @return {@code true} if the color model objects are equal,
- * {@code false} if they are not.
+ * Tests if the specified {@code Object} is an instance
+ * of {@code ComponentColorModel} and equals this
+ * {@code ComponentColorModel}.
+ * @param obj the {@code Object} to test for equality
+ * @return {@code true} if the specified {@code Object}
+ * is an instance of {@code ComponentColorModel} and equals this
+ * {@code ComponentColorModel}; {@code false} otherwise.
*/
+ @Override
public boolean equals(Object obj) {
- if (!super.equals(obj)) {
- return false;
+
+ ComponentColorModel cm = (ComponentColorModel) obj;
+ if (this == cm) {
+ return true;
}
- if (obj.getClass() != getClass()) {
+ if (!super.equals(obj)) {
return false;
}
-
return true;
}
+ /**
+ * Returns the hash code for this ComponentColorModel.
+ *
+ * @return a hash code for this ComponentColorModel.
+ */
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 79 * hash + super.hashCode();
+ return hash;
+ }
+
}
< prev index next >