]> source.dussan.org Git - poi.git/commitdiff
findbugs: add missing equals and hashCode for classes with a compareTo method
authorJaven O'Neal <onealj@apache.org>
Sun, 29 Nov 2015 14:33:28 +0000 (14:33 +0000)
committerJaven O'Neal <onealj@apache.org>
Sun, 29 Nov 2015 14:33:28 +0000 (14:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1717068 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java

index 068f5465c380f940f6e778195159f23cb2db9fc2..5a1351f385417abc9a1eb0968caeda7d72feaa2e 100644 (file)
@@ -537,5 +537,25 @@ public class SXSSFRow implements Row, Comparable<SXSSFRow>
         Integer otherRow = other.getRowNum();
         return thisRow.compareTo(otherRow);
     }
+
+    @Override
+    public boolean equals(Object obj)
+    {
+        if (!(obj instanceof SXSSFRow))
+        {
+            return false;
+        }
+        SXSSFRow other = (SXSSFRow) obj;
+
+        return (this.getRowNum() == other.getRowNum()) &&
+               (this.getSheet() == other.getSheet());
+    }
+
+    @Override
+    public int hashCode() {
+        return (getSheet().hashCode() << 16) + getRowNum();
+    }
+
+
 }
 
index 7f5fe0b5458db79be424d2b87bcec67e75fe60f1..14680572e3775f4cdf087a42b91f481a683e2b0e 100644 (file)
@@ -149,6 +149,24 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
         return thisRow.compareTo(otherRow);
     }
 
+    @Override
+    public boolean equals(Object obj)
+    {
+        if (!(obj instanceof XSSFRow))
+        {
+            return false;
+        }
+        XSSFRow other = (XSSFRow) obj;
+
+        return (this.getRowNum() == other.getRowNum()) &&
+               (this.getSheet() == other.getSheet());
+    }
+
+    @Override
+    public int hashCode() {
+        return _row.hashCode();
+    }
+
     /**
      * Use this to create new cells within the row and return it.
      * <p>