]> source.dussan.org Git - poi.git/commitdiff
bug 59279: add Comment.equals and hashCode methods
authorJaven O'Neal <onealj@apache.org>
Fri, 17 Jun 2016 08:56:10 +0000 (08:56 +0000)
committerJaven O'Neal <onealj@apache.org>
Fri, 17 Jun 2016 08:56:10 +0000 (08:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1748814 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/usermodel/HSSFComment.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java

index 23126d451fe6e000b0ebbef3b081f28439ac169c..0013bd12e1e807ddda7a344006103e3639aa3817 100644 (file)
@@ -320,4 +320,18 @@ public class HSSFComment extends HSSFTextbox implements Comment {
             setPropertyValue(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__PRINT, false, false, property.getPropertyValue() & GROUP_SHAPE_NOT_HIDDEN_MASK));
         }
     }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof HSSFComment)) {
+            return false;
+        }
+        HSSFComment other = (HSSFComment) obj;
+        return getNoteRecord().equals(other.getNoteRecord());
+    }
+
+    @Override
+    public int hashCode() {
+        return ((getRow()*17) + getColumn())*31;
+    }
 }
index 4449757a7684333474e5bf9af1dee0fcc7db54cb..ce891a4b965fb6ec6aa02dc203c087e2af56f390 100644 (file)
@@ -239,4 +239,19 @@ public class XSSFComment implements Comment {
     protected CTShape getCTShape(){
         return _vmlShape;
     }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof XSSFComment)) {
+            return false;
+        }
+        XSSFComment other = (XSSFComment) obj;
+        return ((getCTComment() == other.getCTComment()) &&
+                (getCTShape() == other.getCTShape())); 
+    }
+
+    @Override
+    public int hashCode() {
+        return ((getRow()*17) + getColumn())*31;
+    }
 }