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 { Oas20ResponseDefinition } from '../../openapi/v2/models/Oas20ResponseDefinition';
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_20 = /** @class */ (function (_super) {
    __extends(ReplaceResponseDefinitionCommand_20, _super);
    function ReplaceResponseDefinitionCommand_20(old, replacement) {
        var _this = this;
        if (((old != null && old instanceof Oas20ResponseDefinition) || old === null) && ((replacement != null && replacement instanceof Oas20ResponseDefinition) || 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_20.prototype.removeNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_v2_models_Oas20ResponseDefinition = function (doc, node) {
        var doc20 = doc;
        doc20.responses.removeResponse(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 {Oas20ResponseDefinition} node
     */
    ReplaceResponseDefinitionCommand_20.prototype.removeNode = function (doc, node) {
        if (((doc != null && doc instanceof Document) || doc === null) && ((node != null && node instanceof Oas20ResponseDefinition) || node === null)) {
            return this.removeNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_v2_models_Oas20ResponseDefinition(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_20.prototype.addNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_v2_models_Oas20ResponseDefinition = function (doc, node) {
        var doc20 = doc;
        node._ownerDocument = doc20;
        node._parent = doc20.responses;
        doc20.responses.addResponse(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 {Oas20ResponseDefinition} node
     */
    ReplaceResponseDefinitionCommand_20.prototype.addNode = function (doc, node) {
        if (((doc != null && doc instanceof Document) || doc === null) && ((node != null && node instanceof Oas20ResponseDefinition) || node === null)) {
            return this.addNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_v2_models_Oas20ResponseDefinition(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 {Oas20ResponseDefinition}
     */
    ReplaceResponseDefinitionCommand_20.prototype.readNode = function (doc, node) {
        var doc20 = doc;
        var definition = doc20.responses.createResponse(this._defName);
        Library.readNode(node, definition);
        return definition;
    };
    return ReplaceResponseDefinitionCommand_20;
}(ReplaceNodeCommand));
export { ReplaceResponseDefinitionCommand_20 };
ReplaceResponseDefinitionCommand_20["__class"] = "io.apicurio.datamodels.cmd.commands.ReplaceResponseDefinitionCommand_20";
ReplaceResponseDefinitionCommand_20["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=ReplaceResponseDefinitionCommand_20.js.map