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
This commit is contained in:
Javen O'Neal 2015-11-29 14:33:28 +00:00
parent d471500512
commit da8eb997cd
2 changed files with 38 additions and 0 deletions

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();
}
}

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>