// Why was this restriction here? -- BRC
// assert newAbstractMapWorkspace.getRoot().equals(newParent) != true;
assert this.getRoot().equals(node) != true;
MapNode oldParent = node.getParent();
Name oldName = node.getName().getName();
if (this.equals(newAbstractMapWorkspace) && node.getParent().getUuid().equals(newParent.getUuid())
&& node.equals(beforeNode)) {
// Trivial move of a node to its parent before itself
return;
}
if (oldParent != null) {
boolean removed = oldParent.removeChild(node);
assert removed == true;
node.setParent(null);
correctSameNameSiblingIndexes(context, oldParent, oldName);
}
node.setParent(newParent);
Name newName = oldName;
if (desiredNewName != null) {
newName = desiredNewName;
node.setName(context.getValueFactories().getPathFactory().createSegment(desiredNewName, 1));
}