Browse Source

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
pull/28/head
Javen O'Neal 8 years ago
parent
commit
5ee6c34217

+ 20
- 0
src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java View 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();
}


}


+ 18
- 0
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java View 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>

Loading…
Cancel
Save