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 { LoggerCompat } from '../../compat/LoggerCompat';
import { SecurityScheme } from '../../core/models/common/SecurityScheme';
import { NewSecuritySchemeCommand } from './NewSecuritySchemeCommand';
/**
 * @author eric.wittmann@gmail.com
 * @extends NewSecuritySchemeCommand
 * @class
 */
var NewSecuritySchemeCommand_30 = /** @class */ (function (_super) {
    __extends(NewSecuritySchemeCommand_30, _super);
    function NewSecuritySchemeCommand_30(scheme) {
        var _this = this;
        if (((scheme != null && scheme instanceof SecurityScheme) || scheme === null)) {
            var __args = arguments;
            _this = _super.call(this, scheme) || this;
            if (_this._nullComponents === undefined)
                _this._nullComponents = false;
            if (_this._nullComponents === undefined)
                _this._nullComponents = false;
        }
        else if (scheme === undefined) {
            var __args = arguments;
            _this = _super.call(this) || this;
            if (_this._nullComponents === undefined)
                _this._nullComponents = false;
            if (_this._nullComponents === undefined)
                _this._nullComponents = false;
        }
        else
            throw new Error('invalid overload');
        return _this;
    }
    /**
     * @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
     * @param {Document} document
     */
    NewSecuritySchemeCommand_30.prototype.execute = function (document) {
        LoggerCompat.info("[NewSecuritySchemeCommand] Executing.");
        var doc30 = document;
        this._nullComponents = false;
        if (this.isNullOrUndefined(doc30.components)) {
            doc30.components = doc30.createComponents();
            this._nullComponents = true;
        }
        if (this.isNullOrUndefined(doc30.components.getSecurityScheme(this._schemeName))) {
            var scheme = doc30.components.createSecurityScheme(this._schemeName);
            Library.readNode(this._scheme, scheme);
            doc30.components.addSecurityScheme(this._schemeName, scheme);
            this._schemeExisted = false;
        }
        else {
            this._schemeExisted = true;
        }
    };
    /**
     * @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
     * @param {Document} document
     */
    NewSecuritySchemeCommand_30.prototype.undo = function (document) {
        LoggerCompat.info("[NewSecuritySchemeCommand] Reverting.");
        if (this._schemeExisted) {
            return;
        }
        var doc30 = document;
        if (this._nullComponents) {
            doc30.components = null;
            return;
        }
        doc30.components.removeSecurityScheme(this._schemeName);
    };
    return NewSecuritySchemeCommand_30;
}(NewSecuritySchemeCommand));
export { NewSecuritySchemeCommand_30 };
NewSecuritySchemeCommand_30["__class"] = "io.apicurio.datamodels.cmd.commands.NewSecuritySchemeCommand_30";
NewSecuritySchemeCommand_30["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=NewSecuritySchemeCommand_30.js.map