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 { AddSchemaDefinitionCommand } from './AddSchemaDefinitionCommand';
/**
 * OAI version 3.0.x impl.
 * @author eric.wittmann@gmail.com
 * @extends AddSchemaDefinitionCommand
 * @class
 */
var AddSchemaDefinitionCommand_30 = /** @class */ (function (_super) {
    __extends(AddSchemaDefinitionCommand_30, _super);
    function AddSchemaDefinitionCommand_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.AddSchemaDefinitionCommand#defExists(io.apicurio.datamodels.openapi.models.OasDocument)
     * @param {OasDocument} document
     * @return {boolean}
     */
    AddSchemaDefinitionCommand_30.prototype.defExists = function (document) {
        var doc30 = document;
        if (this.isNullOrUndefined(doc30.components)) {
            return false;
        }
        return !this.isNullOrUndefined(doc30.components.getSchemaDefinition(this._newDefinitionName));
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.AddSchemaDefinitionCommand#prepareDocumentForDef(io.apicurio.datamodels.openapi.models.OasDocument)
     * @param {OasDocument} document
     */
    AddSchemaDefinitionCommand_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.AddSchemaDefinitionCommand#createSchemaDefinition(io.apicurio.datamodels.openapi.models.OasDocument)
     * @param {OasDocument} document
     * @return {OasSchema}
     */
    AddSchemaDefinitionCommand_30.prototype.createSchemaDefinition = function (document) {
        var doc30 = document;
        var definition = doc30.components.createSchemaDefinition(this._newDefinitionName);
        Library.readNode(this._newDefinitionObj, definition);
        return definition;
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.AddSchemaDefinitionCommand#addDefinition(io.apicurio.datamodels.openapi.models.OasDocument, io.apicurio.datamodels.openapi.models.OasSchema)
     * @param {OasDocument} document
     * @param {OasSchema} definition
     */
    AddSchemaDefinitionCommand_30.prototype.addDefinition = function (document, definition) {
        var doc30 = document;
        doc30.components.addSchemaDefinition(this._newDefinitionName, definition);
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.AddSchemaDefinitionCommand#removeDefinition(io.apicurio.datamodels.openapi.models.OasDocument)
     * @param {OasDocument} document
     */
    AddSchemaDefinitionCommand_30.prototype.removeDefinition = function (document) {
        var doc30 = document;
        if (this._nullComponents) {
            doc30.components = null;
        }
        else {
            doc30.components.removeSchemaDefinition(this._newDefinitionName);
        }
    };
    return AddSchemaDefinitionCommand_30;
}(AddSchemaDefinitionCommand));
export { AddSchemaDefinitionCommand_30 };
AddSchemaDefinitionCommand_30["__class"] = "io.apicurio.datamodels.cmd.commands.AddSchemaDefinitionCommand_30";
AddSchemaDefinitionCommand_30["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=AddSchemaDefinitionCommand_30.js.map