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 { ModelUtils } from '../util/ModelUtils';
import { RenameSchemaDefinitionCommand } from './RenameSchemaDefinitionCommand';
/**
 * @author eric.wittmann@gmail.com
 * @extends RenameSchemaDefinitionCommand
 * @class
 */
var RenameSchemaDefinitionCommand_30 = /** @class */ (function (_super) {
    __extends(RenameSchemaDefinitionCommand_30, _super);
    function RenameSchemaDefinitionCommand_30(oldName, newName) {
        var _this = this;
        if (((typeof oldName === 'string') || oldName === null) && ((typeof newName === 'string') || newName === null)) {
            var __args = arguments;
            _this = _super.call(this, oldName, newName) || this;
        }
        else if (oldName === undefined && newName === undefined) {
            var __args = arguments;
            _this = _super.call(this) || this;
        }
        else
            throw new Error('invalid overload');
        return _this;
    }
    /**
     * @see io.apicurio.datamodels.cmd.commands.RenameSchemaDefinitionCommand#_nameToReference(java.lang.String)
     * @param {string} name
     * @return {string}
     */
    RenameSchemaDefinitionCommand_30.prototype._nameToReference = function (name) {
        return "#/components/schemas/" + name;
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.RenameSchemaDefinitionCommand#_renameSchemaDefinition(io.apicurio.datamodels.openapi.models.OasDocument, java.lang.String, java.lang.String)
     * @param {OasDocument} document
     * @param {string} fromName
     * @param {string} toName
     * @return {boolean}
     */
    RenameSchemaDefinitionCommand_30.prototype._renameSchemaDefinition = function (document, fromName, toName) {
        var doc30 = document;
        if (this.isNullOrUndefined(doc30.components) || this.isNullOrUndefined(doc30.components.schemas)) {
            return false;
        }
        if (ModelUtils.isDefined(doc30.components.getSchemaDefinition(toName))) {
            return false;
        }
        var schemaDef = doc30.components.removeSchemaDefinition(fromName);
        schemaDef.rename(toName);
        doc30.components.addSchemaDefinition(toName, schemaDef);
        return true;
    };
    return RenameSchemaDefinitionCommand_30;
}(RenameSchemaDefinitionCommand));
export { RenameSchemaDefinitionCommand_30 };
RenameSchemaDefinitionCommand_30["__class"] = "io.apicurio.datamodels.cmd.commands.RenameSchemaDefinitionCommand_30";
RenameSchemaDefinitionCommand_30["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=RenameSchemaDefinitionCommand_30.js.map