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';
/**
 * Models an OpenAPI 2.0 responses.
 * @author eric.wittmann@gmail.com
 * @class
 * @extends Node
 */
var Oas20ResponseDefinitions = /** @class */ (function (_super) {
    __extends(Oas20ResponseDefinitions, _super);
    function Oas20ResponseDefinitions() {
        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
     */
    Oas20ResponseDefinitions.prototype.accept = function (visitor) {
        var viz = visitor;
        viz.visitResponseDefinitions(this);
    };
    /**
     * Returns a single response by name.
     * @param {string} name
     * @return {Oas20ResponseDefinition}
     */
    Oas20ResponseDefinitions.prototype.getResponse = function (name) {
        return /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(this.items, name);
    };
    /**
     * Returns an array of all the responses.
     * @return {Oas20ResponseDefinition[]}
     */
    Oas20ResponseDefinitions.prototype.getResponses = 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 response.
     * @param {string} name
     * @param {Oas20ResponseDefinition} response
     * @return {Oas20ResponseDefinition}
     */
    Oas20ResponseDefinitions.prototype.addResponse = function (name, response) {
        /* put */ (this.items[name] = response);
        return response;
    };
    /**
     * Removes a response by name.
     * @param {string} name
     * @return {Oas20ResponseDefinition}
     */
    Oas20ResponseDefinitions.prototype.removeResponse = 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 response names.
     * @return {string[]}
     */
    Oas20ResponseDefinitions.prototype.getResponseNames = 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 Response object.
     * @param {string} name
     * @return {Oas20ResponseDefinition}
     */
    Oas20ResponseDefinitions.prototype.createResponse = function (name) {
        var rval = new Oas20ResponseDefinition(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 {Oas20ResponseDefinition}
     */
    Oas20ResponseDefinitions.prototype.getItem = function (name) {
        return this.getResponse(name);
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#getItems()
     * @return {Oas20ResponseDefinition[]}
     */
    Oas20ResponseDefinitions.prototype.getItems = function () {
        return this.getResponses();
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#getItemNames()
     * @return {string[]}
     */
    Oas20ResponseDefinitions.prototype.getItemNames = function () {
        return this.getResponseNames();
    };
    Oas20ResponseDefinitions.prototype.addItem$java_lang_String$io_apicurio_datamodels_openapi_v2_models_Oas20ResponseDefinition = function (name, item) {
        this.addResponse(name, item);
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#addItem(java.lang.String, io.apicurio.datamodels.core.models.Node)
     * @param {string} name
     * @param {Oas20ResponseDefinition} item
     */
    Oas20ResponseDefinitions.prototype.addItem = function (name, item) {
        if (((typeof name === 'string') || name === null) && ((item != null && item instanceof Oas20ResponseDefinition) || item === null)) {
            return this.addItem$java_lang_String$io_apicurio_datamodels_openapi_v2_models_Oas20ResponseDefinition(name, item);
        }
        else
            throw new Error('invalid overload');
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#deleteItem(java.lang.String)
     * @param {string} name
     * @return {Oas20ResponseDefinition}
     */
    Oas20ResponseDefinitions.prototype.deleteItem = function (name) {
        return this.removeResponse(name);
    };
    return Oas20ResponseDefinitions;
}(Node));
export { Oas20ResponseDefinitions };
Oas20ResponseDefinitions["__class"] = "io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinitions";
Oas20ResponseDefinitions["__interfaces"] = ["io.apicurio.datamodels.core.models.IVisitable", "io.apicurio.datamodels.core.models.IIndexedNode"];
import { Oas20ResponseDefinition } from './Oas20ResponseDefinition';
//# sourceMappingURL=Oas20ResponseDefinitions.js.map