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 2.0 impl.
 * @author eric.wittmann@gmail.com
 * @extends AddSchemaDefinitionCommand
 * @class
 */
var AddSchemaDefinitionCommand_20 = /** @class */ (function (_super) {
    __extends(AddSchemaDefinitionCommand_20, _super);
    function AddSchemaDefinitionCommand_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.AddSchemaDefinitionCommand#defExists(io.apicurio.datamodels.openapi.models.OasDocument)
     * @param {OasDocument} document
     * @return {boolean}
     */
    AddSchemaDefinitionCommand_20.prototype.defExists = function (document) {
        var doc20 = document;
        if (this.isNullOrUndefined(doc20.definitions)) {
            return false;
        }
        return !this.isNullOrUndefined(doc20.definitions.getDefinition(this._newDefinitionName));
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.AddSchemaDefinitionCommand#prepareDocumentForDef(io.apicurio.datamodels.openapi.models.OasDocument)
     * @param {OasDocument} document
     */
    AddSchemaDefinitionCommand_20.prototype.prepareDocumentForDef = function (document) {
        var doc20 = document;
        if (this.isNullOrUndefined(doc20.definitions)) {
            doc20.definitions = doc20.createDefinitions();
            this._nullDefinitions = true;
        }
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.AddSchemaDefinitionCommand#createSchemaDefinition(io.apicurio.datamodels.openapi.models.OasDocument)
     * @param {OasDocument} document
     * @return {OasSchema}
     */
    AddSchemaDefinitionCommand_20.prototype.createSchemaDefinition = function (document) {
        var doc20 = document;
        var definition = doc20.definitions.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_20.prototype.addDefinition = function (document, definition) {
        var doc20 = document;
        var def20 = definition;
        doc20.definitions.addDefinition(this._newDefinitionName, def20);
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.AddSchemaDefinitionCommand#removeDefinition(io.apicurio.datamodels.openapi.models.OasDocument)
     * @param {OasDocument} document
     */
    AddSchemaDefinitionCommand_20.prototype.removeDefinition = function (document) {
        var doc20 = document;
        if (this._nullDefinitions) {
            doc20.definitions = null;
        }
        else {
            doc20.definitions.removeDefinition(this._newDefinitionName);
        }
    };
    return AddSchemaDefinitionCommand_20;
}(AddSchemaDefinitionCommand));
export { AddSchemaDefinitionCommand_20 };
AddSchemaDefinitionCommand_20["__class"] = "io.apicurio.datamodels.cmd.commands.AddSchemaDefinitionCommand_20";
AddSchemaDefinitionCommand_20["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=AddSchemaDefinitionCommand_20.js.map