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 { Document } from '../../core/models/Document';
import { Oas30ResponseDefinition } from '../../openapi/v3/models/Oas30ResponseDefinition';
import { ReplaceNodeCommand } from './ReplaceNodeCommand';
/**
 * A command used to replace a response definition with a newer version.
 * @author eric.wittmann@gmail.com
 * @extends ReplaceNodeCommand
 * @class
 */
var ReplaceResponseDefinitionCommand_30 = /** @class */ (function (_super) {
    __extends(ReplaceResponseDefinitionCommand_30, _super);
    function ReplaceResponseDefinitionCommand_30(old, replacement) {
        var _this = this;
        if (((old != null && old instanceof Oas30ResponseDefinition) || old === null) && ((replacement != null && replacement instanceof Oas30ResponseDefinition) || replacement === null)) {
            var __args = arguments;
            _this = _super.call(this, old, replacement) || this;
            if (_this._defName === undefined)
                _this._defName = null;
            if (_this._defName === undefined)
                _this._defName = null;
            (function () {
                _this._defName = old.getName();
            })();
        }
        else if (old === undefined && replacement === undefined) {
            var __args = arguments;
            _this = _super.call(this) || this;
            if (_this._defName === undefined)
                _this._defName = null;
            if (_this._defName === undefined)
                _this._defName = null;
        }
        else
            throw new Error('invalid overload');
        return _this;
    }
    ReplaceResponseDefinitionCommand_30.prototype.removeNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_v3_models_Oas30ResponseDefinition = function (doc, node) {
        var doc30 = doc;
        doc30.components.removeResponseDefinition(node.getName());
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.ReplaceNodeCommand#removeNode(io.apicurio.datamodels.core.models.Document, io.apicurio.datamodels.core.models.Node)
     * @param {Document} doc
     * @param {Oas30ResponseDefinition} node
     */
    ReplaceResponseDefinitionCommand_30.prototype.removeNode = function (doc, node) {
        if (((doc != null && doc instanceof Document) || doc === null) && ((node != null && node instanceof Oas30ResponseDefinition) || node === null)) {
            return this.removeNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_v3_models_Oas30ResponseDefinition(doc, node);
        }
        else if (((doc != null && doc instanceof Document) || doc === null) && ((node != null) || node === null)) {
            throw new Error('cannot invoke abstract overloaded method... check your argument(s) type(s)');
        }
        else
            throw new Error('invalid overload');
    };
    ReplaceResponseDefinitionCommand_30.prototype.addNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_v3_models_Oas30ResponseDefinition = function (doc, node) {
        var doc30 = doc;
        node._ownerDocument = doc;
        node._parent = doc30.components;
        doc30.components.addResponseDefinition(node.getName(), node);
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.ReplaceNodeCommand#addNode(io.apicurio.datamodels.core.models.Document, io.apicurio.datamodels.core.models.Node)
     * @param {Document} doc
     * @param {Oas30ResponseDefinition} node
     */
    ReplaceResponseDefinitionCommand_30.prototype.addNode = function (doc, node) {
        if (((doc != null && doc instanceof Document) || doc === null) && ((node != null && node instanceof Oas30ResponseDefinition) || node === null)) {
            return this.addNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_v3_models_Oas30ResponseDefinition(doc, node);
        }
        else if (((doc != null && doc instanceof Document) || doc === null) && ((node != null) || node === null)) {
            throw new Error('cannot invoke abstract overloaded method... check your argument(s) type(s)');
        }
        else
            throw new Error('invalid overload');
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.ReplaceNodeCommand#readNode(io.apicurio.datamodels.core.models.Document, java.lang.Object)
     * @param {Document} doc
     * @param {*} node
     * @return {Oas30ResponseDefinition}
     */
    ReplaceResponseDefinitionCommand_30.prototype.readNode = function (doc, node) {
        var doc30 = doc;
        var definition = doc30.components.createResponseDefinition(this._defName);
        Library.readNode(node, definition);
        return definition;
    };
    return ReplaceResponseDefinitionCommand_30;
}(ReplaceNodeCommand));
export { ReplaceResponseDefinitionCommand_30 };
ReplaceResponseDefinitionCommand_30["__class"] = "io.apicurio.datamodels.cmd.commands.ReplaceResponseDefinitionCommand_30";
ReplaceResponseDefinitionCommand_30["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=ReplaceResponseDefinitionCommand_30.js.map