Skip to content

Commit

Permalink
Use QNameUtil.match in MapXNode implementation
Browse files Browse the repository at this point in the history
This is required in order to have consistant RawType equals between
XML (oid is attribute without ns) and JSON (oid may get assigned namespace
based on enclosing types).
  • Loading branch information
tonydamage committed Feb 11, 2021
1 parent 1565668 commit 96ca125
Showing 1 changed file with 12 additions and 3 deletions.
Expand Up @@ -155,8 +155,7 @@ private XNodeImpl removeByFullScan(QName key) {
if (QNameUtil.match(key, entry.getKey())) {
iterator.remove();
unqualifiedSubnodeNames.remove(key.getLocalPart());
throw new IllegalStateException("Removing unqualified: " + key);
//return entry.getValue();
return entry.getValue();
}
}
return null;
Expand Down Expand Up @@ -277,10 +276,20 @@ public boolean equals(Object o) {
return false;
}
MapXNodeImpl other = (MapXNodeImpl) o;
return MiscUtil.unorderedCollectionEquals(this.subnodes.entrySet(), other.subnodes.entrySet()) &&

return MiscUtil.unorderedCollectionEquals(this.subnodes.entrySet(), other.subnodes.entrySet(), MapXNodeImpl::equals) &&
metadataEquals(this.metadataNodes, other.metadataNodes);
}

static boolean equals(Map.Entry<QName, XNodeImpl> left, Map.Entry<QName, XNodeImpl> right) {
QName leftName = left.getKey();
QName rightName = right.getKey();
if(!QNameUtil.match(leftName, rightName)) {
return false;
}
return left.getValue().equals(right.getValue());
}

@Override
public int hashCode() {
int result = 0xCAFEBABE;
Expand Down

0 comments on commit 96ca125

Please sign in to comment.