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:
parent
434f05058e
commit
2a7cebf8c0
@ -499,28 +499,35 @@ public class CellReference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether this cell reference is equal to another object.
|
* Checks whether this cell reference is equal to another object.
|
||||||
* <p>
|
* <p>
|
||||||
* Two cells references are assumed to be equal if their string representations
|
* Two cells references are assumed to be equal if their string representations
|
||||||
* ({@link #formatAsString()} are equal.
|
* ({@link #formatAsString()} are equal.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o){
|
public boolean equals(Object o){
|
||||||
if(!(o instanceof CellReference)) {
|
if (this == o) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
CellReference cr = (CellReference) o;
|
if(!(o instanceof CellReference)) {
|
||||||
return _rowIndex == cr._rowIndex
|
return false;
|
||||||
&& _colIndex == cr._colIndex
|
}
|
||||||
&& _isRowAbs == cr._isColAbs
|
CellReference cr = (CellReference) o;
|
||||||
&& _isColAbs == cr._isColAbs;
|
return _rowIndex == cr._rowIndex
|
||||||
}
|
&& _colIndex == cr._colIndex
|
||||||
|
&& _isRowAbs == cr._isRowAbs
|
||||||
|
&& _isColAbs == cr._isColAbs;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
assert false : "hashCode not designed";
|
int result = 17;
|
||||||
return 42; // any arbitrary constant will do
|
result = 31 * result + _rowIndex;
|
||||||
}
|
result = 31 * result + _colIndex;
|
||||||
|
result = 31 * result + (_isRowAbs ? 1 : 0);
|
||||||
|
result = 31 * result + (_isColAbs ? 1 : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user