var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/* Generated from Java with JSweet 2.3.7 - http://www.jsweet.org */
import { Library } from '../../Library';
import { AbstractCommand } from '../AbstractCommand';
import { LoggerCompat } from '../../compat/LoggerCompat';
/**
 * A command used to delete all tags from a document.
 * @author eric.wittmann@gmail.com
 * @extends AbstractCommand
 * @class
 */
var DeleteAllTagsCommand = /** @class */ (function (_super) {
    __extends(DeleteAllTagsCommand, _super);
    function DeleteAllTagsCommand() {
        var _this = _super.call(this) || this;
        if (_this._oldTags === undefined)
            _this._oldTags = null;
        return _this;
    }
    /**
     * @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
     * @param {Document} document
     */
    DeleteAllTagsCommand.prototype.execute = function (document) {
        var _this = this;
        LoggerCompat.info("[DeleteAllTagsCommand] Executing.");
        this._oldTags = ([]);
        if (!this.isNullOrUndefined(document.tags)) {
            document.tags.forEach(function (tag) {
                /* add */ (_this._oldTags.push(Library.writeNode(tag)) > 0);
            });
        }
        var odoc = document;
        odoc.tags = ([]);
    };
    /**
     * @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
     * @param {Document} document
     */
    DeleteAllTagsCommand.prototype.undo = function (document) {
        LoggerCompat.info("[DeleteAllTagsCommand] Reverting.");
        if ( /* size */this._oldTags.length === 0) {
            return;
        }
        var odoc = document;
        if (this.isNullOrUndefined(document.tags)) {
            odoc.tags = ([]);
        }
        this._oldTags.forEach(function (oldTag) {
            var tag = document.createTag();
            Library.readNode(oldTag, tag);
            /* add */ (document.tags.push(tag) > 0);
        });
    };
    return DeleteAllTagsCommand;
}(AbstractCommand));
export { DeleteAllTagsCommand };
DeleteAllTagsCommand["__class"] = "io.apicurio.datamodels.cmd.commands.DeleteAllTagsCommand";
DeleteAllTagsCommand["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=DeleteAllTagsCommand.js.map