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 { SimplifiedParameterType } from '../models/SimplifiedParameterType';
import { LoggerCompat } from '../../compat/LoggerCompat';
import { Parameter } from '../../core/models/common/Parameter';
import { ChangeParameterTypeCommand_20 } from './ChangeParameterTypeCommand_20';
/**
 * OAI 2.0 impl specialized for changing parameter definitions.
 * @author eric.wittmann@gmail.com
 * @extends ChangeParameterTypeCommand_20
 * @class
 */
var ChangeParameterDefinitionTypeCommand_20 = /** @class */ (function (_super) {
    __extends(ChangeParameterDefinitionTypeCommand_20, _super);
    function ChangeParameterDefinitionTypeCommand_20(parameter, newType) {
        var _this = this;
        if (((parameter != null && parameter instanceof Parameter) || parameter === null) && ((newType != null && newType instanceof SimplifiedParameterType) || newType === null)) {
            var __args = arguments;
            _this = _super.call(this, parameter, newType) || this;
        }
        else if (parameter === undefined && newType === undefined) {
            var __args = arguments;
            _this = _super.call(this) || this;
        }
        else
            throw new Error('invalid overload');
        return _this;
    }
    /**
     * @see io.apicurio.datamodels.cmd.commands.ChangeParameterTypeCommand#undo(io.apicurio.datamodels.core.models.Document)
     * @param {Document} document
     */
    ChangeParameterDefinitionTypeCommand_20.prototype.undo = function (document) {
        LoggerCompat.info("[ChangeParameterDefinitionType] Reverting.");
        var param = this._paramPath.resolve(document);
        if (this.isNullOrUndefined(param)) {
            return;
        }
        var doc20 = document;
        doc20.parameters.removeParameter(param.getName());
        var oldParam = doc20.parameters.createParameter(param.getName());
        Library.readNode(this._oldParameter, oldParam);
        doc20.parameters.addParameter(param.getName(), oldParam);
    };
    return ChangeParameterDefinitionTypeCommand_20;
}(ChangeParameterTypeCommand_20));
export { ChangeParameterDefinitionTypeCommand_20 };
ChangeParameterDefinitionTypeCommand_20["__class"] = "io.apicurio.datamodels.cmd.commands.ChangeParameterDefinitionTypeCommand_20";
ChangeParameterDefinitionTypeCommand_20["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=ChangeParameterDefinitionTypeCommand_20.js.map