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 __());
    };
})();
import { Node } from '../../../core/models/Node';
/**
 * Constructor.
 * @class
 * @extends Node
 * @author eric.wittmann@gmail.com
 */
var Oas20ParameterDefinitions = /** @class */ (function (_super) {
    __extends(Oas20ParameterDefinitions, _super);
    function Oas20ParameterDefinitions() {
        var _this = _super.call(this) || this;
        _this.items = ({});
        return _this;
    }
    /**
     * @see io.apicurio.datamodels.core.models.Node#accept(io.apicurio.datamodels.core.visitors.IVisitor)
     * @param {*} visitor
     */
    Oas20ParameterDefinitions.prototype.accept = function (visitor) {
        var viz = visitor;
        viz.visitParameterDefinitions(this);
    };
    /**
     * Returns a single parameter by name.
     * @param {string} name
     * @return {Oas20ParameterDefinition}
     */
    Oas20ParameterDefinitions.prototype.getParameter = function (name) {
        return /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(this.items, name);
    };
    /**
     * Returns an array of all the parameters.
     * @return {Oas20ParameterDefinition[]}
     */
    Oas20ParameterDefinitions.prototype.getParameters = function () {
        var rval = ([]);
        /* addAll */ (function (l1, l2) { return l1.push.apply(l1, l2); })(rval, /* values */ (function (obj) { return Object.keys(obj).map(function (key) { return obj[key]; }); })(this.items));
        return rval;
    };
    /**
     * Adds a parameter.
     * @param {string} name
     * @param {Oas20ParameterDefinition} parameter
     * @return {Oas20ParameterDefinition}
     */
    Oas20ParameterDefinitions.prototype.addParameter = function (name, parameter) {
        /* put */ (this.items[name] = parameter);
        return parameter;
    };
    /**
     * Removes a parameter by name.
     * @param {string} name
     * @return {Oas20ParameterDefinition}
     */
    Oas20ParameterDefinitions.prototype.removeParameter = function (name) {
        var _this = this;
        return /* remove */ (function (map) { var deleted = _this.items[name]; delete _this.items[name]; return deleted; })(this.items);
    };
    /**
     * Gets a list of all the parameter names.
     * @return {string[]}
     */
    Oas20ParameterDefinitions.prototype.getParameterNames = function () {
        var rval = ([]);
        /* addAll */ (function (l1, l2) { return l1.push.apply(l1, l2); })(rval, /* keySet */ Object.keys(this.items));
        return rval;
    };
    /**
     * Creates an OAS 2.0 Parameter object.
     * @param {string} name
     * @return {Oas20ParameterDefinition}
     */
    Oas20ParameterDefinitions.prototype.createParameter = function (name) {
        var rval = new Oas20ParameterDefinition(name);
        rval._ownerDocument = this.ownerDocument();
        rval._parent = this;
        return rval;
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#getItem(java.lang.String)
     * @param {string} name
     * @return {Oas20ParameterDefinition}
     */
    Oas20ParameterDefinitions.prototype.getItem = function (name) {
        return this.getParameter(name);
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#getItems()
     * @return {Oas20ParameterDefinition[]}
     */
    Oas20ParameterDefinitions.prototype.getItems = function () {
        return this.getParameters();
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#getItemNames()
     * @return {string[]}
     */
    Oas20ParameterDefinitions.prototype.getItemNames = function () {
        return this.getParameterNames();
    };
    Oas20ParameterDefinitions.prototype.addItem$java_lang_String$io_apicurio_datamodels_openapi_v2_models_Oas20ParameterDefinition = function (name, item) {
        this.addParameter(name, item);
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#addItem(java.lang.String, io.apicurio.datamodels.core.models.Node)
     * @param {string} name
     * @param {Oas20ParameterDefinition} item
     */
    Oas20ParameterDefinitions.prototype.addItem = function (name, item) {
        if (((typeof name === 'string') || name === null) && ((item != null && item instanceof Oas20ParameterDefinition) || item === null)) {
            return this.addItem$java_lang_String$io_apicurio_datamodels_openapi_v2_models_Oas20ParameterDefinition(name, item);
        }
        else
            throw new Error('invalid overload');
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#deleteItem(java.lang.String)
     * @param {string} name
     * @return {Oas20ParameterDefinition}
     */
    Oas20ParameterDefinitions.prototype.deleteItem = function (name) {
        return this.removeParameter(name);
    };
    return Oas20ParameterDefinitions;
}(Node));
export { Oas20ParameterDefinitions };
Oas20ParameterDefinitions["__class"] = "io.apicurio.datamodels.openapi.v2.models.Oas20ParameterDefinitions";
Oas20ParameterDefinitions["__interfaces"] = ["io.apicurio.datamodels.core.models.IVisitable", "io.apicurio.datamodels.core.models.IIndexedNode"];
import { Oas20ParameterDefinition } from './Oas20ParameterDefinition';
//# sourceMappingURL=Oas20ParameterDefinitions.js.map