From: Javen O'Neal Date: Sun, 29 Nov 2015 14:33:28 +0000 (+0000) Subject: findbugs: add missing equals and hashCode for classes with a compareTo method X-Git-Tag: REL_3_14_BETA1~53 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=da8eb997cda057aafe433a8b80627e17a3828e22;p=poi.git findbugs: add missing equals and hashCode for classes with a compareTo method git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1717068 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java index 068f5465c3..5a1351f385 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java @@ -537,5 +537,25 @@ public class SXSSFRow implements Row, Comparable 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(); + } + + } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java index 7f5fe0b545..14680572e3 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java @@ -149,6 +149,24 @@ public class XSSFRow implements Row, Comparable { 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. *