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 Oas20Headers = /** @class */ (function (_super) {
    __extends(Oas20Headers, _super);
    function Oas20Headers() {
        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
     */
    Oas20Headers.prototype.accept = function (visitor) {
        var viz = visitor;
        viz.visitHeaders(this);
    };
    /**
     * Creates a header model.
     * @param {string} headerName
     * @return {Oas20Header}
     */
    Oas20Headers.prototype.createHeader = function (headerName) {
        var rval = new Oas20Header(headerName);
        rval._ownerDocument = this.ownerDocument();
        rval._parent = this;
        return rval;
    };
    /**
     * Gets a single header by name.
     * @param {string} headerName
     * @return {Oas20Header}
     */
    Oas20Headers.prototype.getHeader = function (headerName) {
        return /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(this.items, headerName);
    };
    /**
     * Returns an array of all the headers.
     * @return {Oas20Header[]}
     */
    Oas20Headers.prototype.getHeaders = 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;
    };
    /**
     * Returns all the header names.
     * @return {string[]}
     */
    Oas20Headers.prototype.getHeaderNames = function () {
        var rval = ([]);
        /* addAll */ (function (l1, l2) { return l1.push.apply(l1, l2); })(rval, /* keySet */ Object.keys(this.items));
        return rval;
    };
    /**
     * Removes a single header.
     * @param {string} headerName
     * @return {Oas20Header}
     */
    Oas20Headers.prototype.removeHeader = function (headerName) {
        var _this = this;
        return /* remove */ (function (map) { var deleted = _this.items[headerName]; delete _this.items[headerName]; return deleted; })(this.items);
    };
    /**
     * Adds a header.
     * @param {string} headerName
     * @param {Oas20Header} header
     * @return {Oas20Header}
     */
    Oas20Headers.prototype.addHeader = function (headerName, header) {
        /* put */ (this.items[headerName] = header);
        return header;
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#getItem(java.lang.String)
     * @param {string} name
     * @return {Oas20Header}
     */
    Oas20Headers.prototype.getItem = function (name) {
        return this.getHeader(name);
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#getItems()
     * @return {Oas20Header[]}
     */
    Oas20Headers.prototype.getItems = function () {
        return this.getHeaders();
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#getItemNames()
     * @return {string[]}
     */
    Oas20Headers.prototype.getItemNames = function () {
        return this.getHeaderNames();
    };
    Oas20Headers.prototype.addItem$java_lang_String$io_apicurio_datamodels_openapi_v2_models_Oas20Header = function (name, item) {
        this.addHeader(name, item);
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#addItem(java.lang.String, io.apicurio.datamodels.core.models.Node)
     * @param {string} name
     * @param {Oas20Header} item
     */
    Oas20Headers.prototype.addItem = function (name, item) {
        if (((typeof name === 'string') || name === null) && ((item != null && item instanceof Oas20Header) || item === null)) {
            return this.addItem$java_lang_String$io_apicurio_datamodels_openapi_v2_models_Oas20Header(name, item);
        }
        else
            throw new Error('invalid overload');
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#deleteItem(java.lang.String)
     * @param {string} name
     * @return {Oas20Header}
     */
    Oas20Headers.prototype.deleteItem = function (name) {
        return this.removeHeader(name);
    };
    return Oas20Headers;
}(Node));
export { Oas20Headers };
Oas20Headers["__class"] = "io.apicurio.datamodels.openapi.v2.models.Oas20Headers";
Oas20Headers["__interfaces"] = ["io.apicurio.datamodels.core.models.IVisitable", "io.apicurio.datamodels.core.models.IIndexedNode"];
import { Oas20Header } from './Oas20Header';
//# sourceMappingURL=Oas20Headers.js.map