Patch from Shaun Kalley from bug #56023 - On CellReference, implement hashCode, fix the equals(Object) logic, and fix inconsistent whitespace

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1575683 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2014-03-09 09:49:06 +00:00
parent 434f05058e
commit 2a7cebf8c0
1 changed files with 30 additions and 23 deletions

View File

@ -508,19 +508,26 @@ public class CellReference {
*/
@Override
public boolean equals(Object o){
if (this == o) {
return true;
}
if(!(o instanceof CellReference)) {
return false;
}
CellReference cr = (CellReference) o;
return _rowIndex == cr._rowIndex
&& _colIndex == cr._colIndex
&& _isRowAbs == cr._isColAbs
&& _isRowAbs == cr._isRowAbs
&& _isColAbs == cr._isColAbs;
}
@Override
public int hashCode() {
assert false : "hashCode not designed";
return 42; // any arbitrary constant will do
int result = 17;
result = 31 * result + _rowIndex;
result = 31 * result + _colIndex;
result = 31 * result + (_isRowAbs ? 1 : 0);
result = 31 * result + (_isColAbs ? 1 : 0);
return result;
}
}