bug 59279: add Comment.equals and hashCode methods

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1748814 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-06-17 08:56:10 +00:00
parent 720e866a4c
commit 19a0cc12fa
2 changed files with 29 additions and 0 deletions

View File

@ -320,4 +320,18 @@ public class HSSFComment extends HSSFTextbox implements Comment {
setPropertyValue(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__PRINT, false, false, property.getPropertyValue() & GROUP_SHAPE_NOT_HIDDEN_MASK));
}
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof HSSFComment)) {
return false;
}
HSSFComment other = (HSSFComment) obj;
return getNoteRecord().equals(other.getNoteRecord());
}
@Override
public int hashCode() {
return ((getRow()*17) + getColumn())*31;
}
}

View File

@ -239,4 +239,19 @@ public class XSSFComment implements Comment {
protected CTShape getCTShape(){
return _vmlShape;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof XSSFComment)) {
return false;
}
XSSFComment other = (XSSFComment) obj;
return ((getCTComment() == other.getCTComment()) &&
(getCTShape() == other.getCTShape()));
}
@Override
public int hashCode() {
return ((getRow()*17) + getColumn())*31;
}
}