if (this == base) {
return true; // no differences
}
for (Map.Entry<String, PropertyState> entry : properties.entrySet()) {
PropertyState before = base.getProperty(entry.getKey());
PropertyState after = entry.getValue();
if (after == null) {
if (before != null && !diff.propertyDeleted(before)) {
return false;
}
} else if (before == null) {
if (!diff.propertyAdded(after)) {
return false;
}
} else if (!before.equals(after)
&& !diff.propertyChanged(before, after)) {
return false;
}
}
for (Map.Entry<String, NodeState> entry : nodes.entrySet()) {
String name = entry.getKey();
NodeState before = base.getChildNode(name);
NodeState after = entry.getValue();
if (!after.exists()) {
if (before.exists() && !diff.childNodeDeleted(name, before)) {
return false;
}
} else if (!before.exists()) {
if (!diff.childNodeAdded(name, after)) {
return false;
}
} else if (before != after // TODO: fastEquals?
&& !diff.childNodeChanged(name, before, after)) {
return false;
}
}
return this.base.compareAgainstBaseState(base, new NodeStateDiff() {
@Override
public boolean propertyAdded(PropertyState after) {
return properties.containsKey(after.getName())
|| diff.propertyAdded(after);
}
@Override
public boolean propertyChanged(
PropertyState before, PropertyState after) {