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 '../../cmd/util/ModelUtils';
import { NodeCompat } from '../../compat/NodeCompat';
import { ExtensibleNode } from '../../core/models/ExtensibleNode';
/**
 * Constructor.
 * @param {string} path
 * @class
 * @extends ExtensibleNode
 * @author eric.wittmann@gmail.com
 */
var OasPathItem = /** @class */ (function (_super) {
    __extends(OasPathItem, _super);
    function OasPathItem(path) {
        var _this = _super.call(this) || this;
        if (_this._path === undefined)
            _this._path = null;
        if (_this.$ref === undefined)
            _this.$ref = null;
        if (_this.get === undefined)
            _this.get = null;
        if (_this.put === undefined)
            _this.put = null;
        if (_this.post === undefined)
            _this.post = null;
        if (_this.delete === undefined)
            _this.delete = null;
        if (_this.options === undefined)
            _this.options = null;
        if (_this.head === undefined)
            _this.head = null;
        if (_this.patch === undefined)
            _this.patch = null;
        if (_this.parameters === undefined)
            _this.parameters = null;
        _this._path = path;
        return _this;
    }
    /**
     * Rename the path item (change its path value).
     * @param {string} newPath
     */
    OasPathItem.prototype.rename = function (newPath) {
        this._path = newPath;
    };
    /**
     *
     * @return {string}
     */
    OasPathItem.prototype.getReference = function () {
        return this.$ref;
    };
    /**
     *
     * @param {string} reference
     */
    OasPathItem.prototype.setReference = function (reference) {
        this.$ref = reference;
    };
    /**
     * @see io.apicurio.datamodels.openapi.models.IOasParameterParent#getParameters()
     * @return {OasParameter[]}
     */
    OasPathItem.prototype.getParameters = function () {
        return this.parameters;
    };
    /**
     * @see io.apicurio.datamodels.openapi.models.IOasParameterParent#getParametersIn(java.lang.String)
     * @param {string} in
     * @return {OasParameter[]}
     */
    OasPathItem.prototype.getParametersIn = function (__in) {
        var params = ([]);
        if (ModelUtils.isDefined(this.parameters)) {
            this.parameters.forEach((function (params) {
                return function (param) {
                    if (NodeCompat.equals(param.in, __in)) {
                        /* add */ (params.push(param) > 0);
                    }
                };
            })(params));
        }
        return params;
    };
    /**
     * Gets the path string.
     * @return {string}
     */
    OasPathItem.prototype.getPath = function () {
        return this._path;
    };
    /**
     * @see io.apicurio.datamodels.core.models.Node#accept(io.apicurio.datamodels.core.visitors.IVisitor)
     * @param {*} visitor
     */
    OasPathItem.prototype.accept = function (visitor) {
        var oasVisitor = visitor;
        oasVisitor.visitPathItem(this);
    };
    /**
     * Adds a parameter.
     * @param {OasParameter} param
     * @return {OasParameter}
     */
    OasPathItem.prototype.addParameter = function (param) {
        if (this.parameters == null) {
            this.parameters = ([]);
        }
        /* add */ (this.parameters.push(param) > 0);
        return param;
    };
    /**
     * Returns a single, unique parameter identified by "in" and "name" (which are the two
     * properties that uniquely identify a parameter).  Returns null if no parameter is found.
     * @param {string} in
     * @param {string} name
     * @return {OasParameter}
     */
    OasPathItem.prototype.getParameter = function (__in, name) {
        if (this.parameters == null) {
            return null;
        }
        for (var index203 = 0; index203 < this.parameters.length; index203++) {
            var param = this.parameters[index203];
            {
                if (NodeCompat.equals(__in, param.in) && NodeCompat.equals(name, param.name)) {
                    return param;
                }
            }
        }
        return null;
    };
    /**
     * Sets the given operation on this path item.
     * @param {OasOperation} operation
     */
    OasPathItem.prototype.setOperation = function (operation) {
        if (NodeCompat.equals("get", operation.getMethod())) {
            this.get = operation;
        }
        else if (NodeCompat.equals("put", operation.getMethod())) {
            this.put = operation;
        }
        else if (NodeCompat.equals("post", operation.getMethod())) {
            this.post = operation;
        }
        else if (NodeCompat.equals("delete", operation.getMethod())) {
            this.delete = operation;
        }
        else if (NodeCompat.equals("head", operation.getMethod())) {
            this.head = operation;
        }
        else if (NodeCompat.equals("patch", operation.getMethod())) {
            this.patch = operation;
        }
        else if (NodeCompat.equals("options", operation.getMethod())) {
            this.options = operation;
        }
    };
    return OasPathItem;
}(ExtensibleNode));
export { OasPathItem };
OasPathItem["__class"] = "io.apicurio.datamodels.openapi.models.OasPathItem";
OasPathItem["__interfaces"] = ["io.apicurio.datamodels.core.models.IVisitable", "io.apicurio.datamodels.core.models.IReferenceNode", "io.apicurio.datamodels.openapi.models.IOasParameterParent"];
//# sourceMappingURL=OasPathItem.js.map