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 2.0 impl.
 * @author eric.wittmann@gmail.com
 * @extends AddResponseDefinitionCommand
 * @class
 */
var AddResponseDefinitionCommand_20 = /** @class */ (function (_super) {
    __extends(AddResponseDefinitionCommand_20, _super);
    function AddResponseDefinitionCommand_20(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._nullDefinitions === undefined)
                _this._nullDefinitions = false;
            if (_this._nullDefinitions === undefined)
                _this._nullDefinitions = false;
        }
        else if (((typeof definitionName === 'string') || definitionName === null) && from === undefined) {
            var __args = arguments;
            _this = _super.call(this, definitionName) || this;
            if (_this._nullDefinitions === undefined)
                _this._nullDefinitions = false;
            if (_this._nullDefinitions === undefined)
                _this._nullDefinitions = false;
        }
        else if (definitionName === undefined && from === undefined) {
            var __args = arguments;
            _this = _super.call(this) || this;
            if (_this._nullDefinitions === undefined)
                _this._nullDefinitions = false;
            if (_this._nullDefinitions === undefined)
                _this._nullDefinitions = 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_20.prototype.defExists = function (document) {
        var doc20 = document;
        if (this.isNullOrUndefined(doc20.responses)) {
            return false;
        }
        return !this.isNullOrUndefined(doc20.responses.getResponse(this._newDefinitionName));
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.AddResponseDefinitionCommand#prepareDocumentForDef(io.apicurio.datamodels.openapi.models.OasDocument)
     * @param {OasDocument} document
     */
    AddResponseDefinitionCommand_20.prototype.prepareDocumentForDef = function (document) {
        var doc20 = document;
        if (this.isNullOrUndefined(doc20.responses)) {
            doc20.responses = doc20.createResponseDefinitions();
            this._nullDefinitions = true;
        }
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.AddResponseDefinitionCommand#createResponseDefinition(io.apicurio.datamodels.openapi.models.OasDocument)
     * @param {OasDocument} document
     * @return {OasResponse}
     */
    AddResponseDefinitionCommand_20.prototype.createResponseDefinition = function (document) {
        var doc20 = document;
        var definition = doc20.responses.createResponse(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_20.prototype.addDefinition = function (document, definition) {
        var doc20 = document;
        var def20 = definition;
        doc20.responses.addResponse(this._newDefinitionName, def20);
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.AddResponseDefinitionCommand#removeDefinition(io.apicurio.datamodels.openapi.models.OasDocument)
     * @param {OasDocument} document
     */
    AddResponseDefinitionCommand_20.prototype.removeDefinition = function (document) {
        var doc20 = document;
        if (this._nullDefinitions) {
            doc20.responses = null;
        }
        else {
            doc20.responses.removeResponse(this._newDefinitionName);
        }
    };
    return AddResponseDefinitionCommand_20;
}(AddResponseDefinitionCommand));
export { AddResponseDefinitionCommand_20 };
AddResponseDefinitionCommand_20["__class"] = "io.apicurio.datamodels.cmd.commands.AddResponseDefinitionCommand_20";
AddResponseDefinitionCommand_20["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=AddResponseDefinitionCommand_20.js.map