use of io.apicurio.datamodels.core.visitors.IVisitor in project apicurio-data-models by Apicurio.
the class RenameTagDefinitionCommand method _doTagRename.
/**
* Does the work of renaming a tag from one name to another.
* @param document
* @param from
* @param to
* @private
*/
private void _doTagRename(Document document, String from, String to) {
// If the "to" tag already exists, bail out before doing anything
Tag existingTag = this._findTag(document, to);
if (ModelUtils.isDefined(existingTag)) {
return;
}
// Find the tag by name and rename it.
Tag tagToRename = this._findTag(document, from);
if (ModelUtils.isDefined(tagToRename)) {
// Now rename the tag
tagToRename.name = to;
// Rename every **usage** of the tag in the document (all operations)
IVisitor tagRenamer = new TagRenameVisitor(from, to);
VisitorUtil.visitTree(document, tagRenamer, TraverserDirection.down);
}
}