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 { AddResponseDefinitionCommand } from './AddResponseDefinitionCommand';
/**
 * OAI version 3.0.x impl.
 * @author eric.wittmann@gmail.com
 * @extends AddResponseDefinitionCommand
 * @class
 */
var AddResponseDefinitionCommand_30 = /** @class */ (function (_super) {
    __extends(AddResponseDefinitionCommand_30, _super);
    function AddResponseDefinitionCommand_30(definitionName, from) {
        var _this = this;
        if (((typeof definitionName === 'string') || definitionName === null) && ((from != null) || from === null)) {
            var __args = arguments;
            _this = _super.call(this, definitionName, from) || this;
            if (_this._nullComponents === undefined)
                _this._nullComponents = false;
            if (_this._nullComponents === undefined)
                _this._nullComponents = false;
        }
        else if (((typeof definitionName === 'string') || definitionName === null) && from === undefined) {
            var __args = arguments;
            _this = _super.call(this, definitionName) || this;
            if (_this._nullComponents === undefined)
                _this._nullComponents = false;
            if (_this._nullComponents === undefined)
                _this._nullComponents = false;
        }
        else if (definitionName === undefined && from === 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.commands.AddResponseDefinitionCommand#defExists(io.apicurio.datamodels.openapi.models.OasDocument)
     * @param {OasDocument} document
     * @return {boolean}
     */
    AddResponseDefinitionCommand_30.prototype.defExists = function (document) {
        var doc30 = document;
        if (this.isNullOrUndefined(doc30.components)) {
            return false;
        }
        return !this.isNullOrUndefined(doc30.components.getResponseDefinition(this._newDefinitionName));
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.AddResponseDefinitionCommand#prepareDocumentForDef(io.apicurio.datamodels.openapi.models.OasDocument)
     * @param {OasDocument} document
     */
    AddResponseDefinitionCommand_30.prototype.prepareDocumentForDef = function (document) {
        var doc30 = document;
        if (this.isNullOrUndefined(doc30.components)) {
            doc30.components = doc30.createComponents();
            this._nullComponents = true;
        }
        else {
            this._nullComponents = false;
        }
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.AddResponseDefinitionCommand#createResponseDefinition(io.apicurio.datamodels.openapi.models.OasDocument)
     * @param {OasDocument} document
     * @return {OasResponse}
     */
    AddResponseDefinitionCommand_30.prototype.createResponseDefinition = function (document) {
        var doc30 = document;
        var definition = doc30.components.createResponseDefinition(this._newDefinitionName);
        Library.readNode(this._newDefinitionObj, definition);
        return definition;
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.AddResponseDefinitionCommand#addDefinition(io.apicurio.datamodels.openapi.models.OasDocument, io.apicurio.datamodels.openapi.models.OasResponse)
     * @param {OasDocument} document
     * @param {OasResponse} definition
     */
    AddResponseDefinitionCommand_30.prototype.addDefinition = function (document, definition) {
        var doc30 = document;
        doc30.components.addResponseDefinition(this._newDefinitionName, definition);
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.AddResponseDefinitionCommand#removeDefinition(io.apicurio.datamodels.openapi.models.OasDocument)
     * @param {OasDocument} document
     */
    AddResponseDefinitionCommand_30.prototype.removeDefinition = function (document) {
        var doc30 = document;
        if (this._nullComponents) {
            doc30.components = null;
        }
        else {
            doc30.components.removeResponseDefinition(this._newDefinitionName);
        }
    };
    return AddResponseDefinitionCommand_30;
}(AddResponseDefinitionCommand));
export { AddResponseDefinitionCommand_30 };
AddResponseDefinitionCommand_30["__class"] = "io.apicurio.datamodels.cmd.commands.AddResponseDefinitionCommand_30";
AddResponseDefinitionCommand_30["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=AddResponseDefinitionCommand_30.js.map