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 { ModelUtils } from '../util/ModelUtils';
import { DeleteResponseDefinitionCommand } from './DeleteResponseDefinitionCommand';
/**
 * @author eric.wittmann@gmail.com
 * @extends DeleteResponseDefinitionCommand
 * @class
 */
var DeleteResponseDefinitionCommand_30 = /** @class */ (function (_super) {
    __extends(DeleteResponseDefinitionCommand_30, _super);
    function DeleteResponseDefinitionCommand_30(definitionName) {
        var _this = this;
        if (((typeof definitionName === 'string') || definitionName === null)) {
            var __args = arguments;
            _this = _super.call(this, definitionName) || this;
        }
        else if (definitionName === undefined) {
            var __args = arguments;
            _this = _super.call(this) || this;
        }
        else
            throw new Error('invalid overload');
        return _this;
    }
    /**
     * @see io.apicurio.datamodels.cmd.commands.DeleteResponseDefinitionCommand#doDeleteResponseDefinition(io.apicurio.datamodels.core.models.Document)
     * @param {Document} document
     * @return {*}
     */
    DeleteResponseDefinitionCommand_30.prototype.doDeleteResponseDefinition = function (document) {
        var doc30 = document;
        if (ModelUtils.isDefined(doc30.components) && ModelUtils.isDefined(doc30.components.getResponseDefinition(this._definitionName))) {
            var oldDef = doc30.components.removeResponseDefinition(this._definitionName);
            return Library.writeNode(oldDef);
        }
        return null;
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.DeleteResponseDefinitionCommand#doRestoreResponseDefinition(io.apicurio.datamodels.core.models.Document, java.lang.Object)
     * @param {Document} document
     * @param {*} oldDefinition
     */
    DeleteResponseDefinitionCommand_30.prototype.doRestoreResponseDefinition = function (document, oldDefinition) {
        var doc30 = document;
        if (ModelUtils.isDefined(doc30.components)) {
            var schemaDef = doc30.components.createResponseDefinition(this._definitionName);
            Library.readNode(oldDefinition, schemaDef);
            doc30.components.addResponseDefinition(this._definitionName, schemaDef);
        }
    };
    return DeleteResponseDefinitionCommand_30;
}(DeleteResponseDefinitionCommand));
export { DeleteResponseDefinitionCommand_30 };
DeleteResponseDefinitionCommand_30["__class"] = "io.apicurio.datamodels.cmd.commands.DeleteResponseDefinitionCommand_30";
DeleteResponseDefinitionCommand_30["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=DeleteResponseDefinitionCommand_30.js.map