use of io.apicurio.datamodels.core.models.common.Tag in project apicurio-data-models by Apicurio.
the class Oas20to30TransformationVisitor method visitTag.
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitTag(io.apicurio.datamodels.core.models.common.Tag)
*/
@Override
public void visitTag(Tag node) {
Oas30Document parent30 = this.doc30;
Tag tag30 = parent30.addTag(node.name, node.description);
this.mapNode(node, tag30);
}
use of io.apicurio.datamodels.core.models.common.Tag 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);
}
}
use of io.apicurio.datamodels.core.models.common.Tag in project apicurio-data-models by Apicurio.
the class DeleteTagCommand method execute.
/**
* @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void execute(Document document) {
LoggerCompat.info("[DeleteTagCommand] Executing.");
if (this.isNullOrUndefined(document.tags)) {
return;
}
List<Tag> tags = document.tags;
Tag tag = null;
for (Tag t : tags) {
if (NodeCompat.equals(t.name, this._tagName)) {
tag = t;
}
}
this._oldIndex = tags.indexOf(tag);
tags.remove(this._oldIndex);
this._oldTag = Library.writeNode(tag);
}
use of io.apicurio.datamodels.core.models.common.Tag in project apicurio-data-models by Apicurio.
the class NewTagCommand method execute.
/**
* @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void execute(Document document) {
LoggerCompat.info("[NewTagCommand] Executing.");
this._created = false;
if (this.isNullOrUndefined(document.tags)) {
document.tags = new ArrayList<>();
}
Tag tag = this.findTag(document, this._tagName);
if (this.isNullOrUndefined(tag)) {
document.addTag(this._tagName, this._tagDescription);
this._created = true;
}
}
use of io.apicurio.datamodels.core.models.common.Tag in project apicurio-data-models by Apicurio.
the class Oas30Document method createTag.
/**
* @see io.apicurio.datamodels.core.models.Document#createTag()
*/
@Override
public Tag createTag() {
Tag tag = new Oas30Tag();
tag._ownerDocument = this;
tag._parent = this;
return tag;
}
Aggregations