Commit dd8743a6 authored by Ate Douma's avatar Ate Douma

CMS7-7024: hasCode() and equals() methods fixed and properly implemented

parent fd2bab91
......@@ -203,6 +203,20 @@ public class DocumentTypeImpl extends Sealable implements DocumentType {
return fields;
}
public int hashCode() {
return isSealed() ? getName().hashCode() : super.hashCode();
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof DocumentTypeImpl && this.isSealed() && ((Sealable)obj).isSealed()) {
return this.getName().equals(((DocumentTypeImpl)obj).getName());
}
return false;
}
public boolean contains(DocumentTypeImpl other) {
for (String s : other.superTypes) {
if (!isDocumentType(s)) {
......
......@@ -211,10 +211,7 @@ public class EffectiveNodeTypeImpl extends Sealable implements EffectiveNodeType
}
public int hashCode() {
if (isSealed()) {
return this.getPrefix().hashCode() + this.getName().hashCode();
}
return super.hashCode();
return isSealed() ? getName().hashCode() : super.hashCode();
}
public boolean equals(Object obj) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment