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 { OasPathItem } from '../../openapi/models/OasPathItem';
import { ReplaceNodeCommand } from './ReplaceNodeCommand';
/**
 * A command used to replace a path item with a newer version.
 * @author eric.wittmann@gmail.com
 * @extends ReplaceNodeCommand
 * @class
 */
var ReplacePathItemCommand = /** @class */ (function (_super) {
    __extends(ReplacePathItemCommand, _super);
    function ReplacePathItemCommand(old, replacement) {
        var _this = this;
        if (((old != null && old instanceof OasPathItem) || old === null) && ((replacement != null && replacement instanceof OasPathItem) || replacement === null)) {
            var __args = arguments;
            _this = _super.call(this, old, replacement) || this;
            if (_this._pathName === undefined)
                _this._pathName = null;
            if (_this._pathName === undefined)
                _this._pathName = null;
            (function () {
                _this._pathName = replacement.getPath();
            })();
        }
        else if (old === undefined && replacement === undefined) {
            var __args = arguments;
            _this = _super.call(this) || this;
            if (_this._pathName === undefined)
                _this._pathName = null;
            if (_this._pathName === undefined)
                _this._pathName = null;
        }
        else
            throw new Error('invalid overload');
        return _this;
    }
    ReplacePathItemCommand.prototype.removeNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_models_OasPathItem = function (doc, node) {
        var odoc = doc;
        odoc.paths.removePathItem(node.getPath());
    };
    /**
     * @see io.apicurio.datamodels.cmd.commands.ReplaceNodeCommand#removeNode(io.apicurio.datamodels.core.models.Document, io.apicurio.datamodels.core.models.Node)
     * @param {Document} doc
     * @param {OasPathItem} node
     */
    ReplacePathItemCommand.prototype.removeNode = function (doc, node) {
        if (((doc != null && doc instanceof Document) || doc === null) && ((node != null && node instanceof OasPathItem) || node === null)) {
            return this.removeNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_models_OasPathItem(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');
    };
    ReplacePathItemCommand.prototype.addNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_models_OasPathItem = function (doc, node) {
        var odoc = doc;
        node._ownerDocument = odoc;
        node._parent = odoc.paths;
        odoc.paths.addPathItem(this._pathName, 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 {OasPathItem} node
     */
    ReplacePathItemCommand.prototype.addNode = function (doc, node) {
        if (((doc != null && doc instanceof Document) || doc === null) && ((node != null && node instanceof OasPathItem) || node === null)) {
            return this.addNode$io_apicurio_datamodels_core_models_Document$io_apicurio_datamodels_openapi_models_OasPathItem(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 {OasPathItem}
     */
    ReplacePathItemCommand.prototype.readNode = function (doc, node) {
        var odoc = doc;
        var pathItem = odoc.paths.createPathItem(this._pathName);
        Library.readNode(node, pathItem);
        return pathItem;
    };
    return ReplacePathItemCommand;
}(ReplaceNodeCommand));
export { ReplacePathItemCommand };
ReplacePathItemCommand["__class"] = "io.apicurio.datamodels.cmd.commands.ReplacePathItemCommand";
ReplacePathItemCommand["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=ReplacePathItemCommand.js.map