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_20 = /** @class */ (function (_super) {
    __extends(RenameSchemaDefinitionCommand_20, _super);
    function RenameSchemaDefinitionCommand_20(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_20.prototype._nameToReference = function (name) {
        return "#/definitions/" + 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_20.prototype._renameSchemaDefinition = function (document, fromName, toName) {
        var doc20 = document;
        if (this.isNullOrUndefined(doc20.definitions)) {
            return false;
        }
        if (ModelUtils.isDefined(doc20.definitions.getDefinition(toName))) {
            return false;
        }
        var schemaDef = doc20.definitions.removeDefinition(fromName);
        schemaDef.rename(toName);
        doc20.definitions.addDefinition(toName, schemaDef);
        return true;
    };
    return RenameSchemaDefinitionCommand_20;
}(RenameSchemaDefinitionCommand));
export { RenameSchemaDefinitionCommand_20 };
RenameSchemaDefinitionCommand_20["__class"] = "io.apicurio.datamodels.cmd.commands.RenameSchemaDefinitionCommand_20";
RenameSchemaDefinitionCommand_20["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=RenameSchemaDefinitionCommand_20.js.map