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 { Oas30SchemaDefinition } from '../../openapi/v3/models/Oas30SchemaDefinition';
import { ReplaceNodeCommand } from './ReplaceNodeCommand';
/**
 * A command used to replace a definition schema with a newer version.
 * @author eric.wittmann@gmail.com
 * @extends ReplaceNodeCommand
 * @class
 */
var ReplaceSchemaDefinitionCommand_30 = /** @class */ (function (_super) {
    __extends(ReplaceSchemaDefinitionCommand_30, _super);
    function ReplaceSchemaDefinitionCommand_30(old, replacement) {
        var _this = this;
        if (((old != null && old instanceof Oas30SchemaDefinition) || old === null) && ((replacement != null && replacement instanceof Oas30SchemaDefinition) || 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;
    }
    ReplaceSchemaDefinitionCommand_30.prototype.removeNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_v3_models_Oas30SchemaDefinition = function (doc, node) {
        var doc30 = doc;
        doc30.components.removeSchemaDefinition(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 {Oas30SchemaDefinition} node
     */
    ReplaceSchemaDefinitionCommand_30.prototype.removeNode = function (doc, node) {
        if (((doc != null && doc instanceof Document) || doc === null) && ((node != null && node instanceof Oas30SchemaDefinition) || node === null)) {
            return this.removeNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_v3_models_Oas30SchemaDefinition(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');
    };
    ReplaceSchemaDefinitionCommand_30.prototype.addNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_v3_models_Oas30SchemaDefinition = function (doc, node) {
        var doc30 = doc;
        node._ownerDocument = doc;
        node._parent = doc30.components;
        doc30.components.addSchemaDefinition(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 {Oas30SchemaDefinition} node
     */
    ReplaceSchemaDefinitionCommand_30.prototype.addNode = function (doc, node) {
        if (((doc != null && doc instanceof Document) || doc === null) && ((node != null && node instanceof Oas30SchemaDefinition) || node === null)) {
            return this.addNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_v3_models_Oas30SchemaDefinition(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 {Oas30SchemaDefinition}
     */
    ReplaceSchemaDefinitionCommand_30.prototype.readNode = function (doc, node) {
        var doc30 = doc;
        var definition = doc30.components.createSchemaDefinition(this._defName);
        Library.readNode(node, definition);
        return definition;
    };
    return ReplaceSchemaDefinitionCommand_30;
}(ReplaceNodeCommand));
export { ReplaceSchemaDefinitionCommand_30 };
ReplaceSchemaDefinitionCommand_30["__class"] = "io.apicurio.datamodels.cmd.commands.ReplaceSchemaDefinitionCommand_30";
ReplaceSchemaDefinitionCommand_30["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=ReplaceSchemaDefinitionCommand_30.js.map