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 { NodeCompat } from '../../compat/NodeCompat';
import { Constants } from '../../core/Constants';
import { ExtensibleNode } from '../../core/models/ExtensibleNode';
/**
 * Models an OpenAPI responses.
 * @author eric.wittmann@gmail.com
 * @class
 * @extends ExtensibleNode
 */
var OasResponses = /** @class */ (function (_super) {
    __extends(OasResponses, _super);
    function OasResponses() {
        var _this = _super.call(this) || this;
        if (_this.default_ === undefined)
            _this.default_ = null;
        if (_this._responses === undefined)
            _this._responses = null;
        return _this;
    }
    /**
     * @see io.apicurio.datamodels.core.models.Node#accept(io.apicurio.datamodels.core.visitors.IVisitor)
     * @param {*} visitor
     */
    OasResponses.prototype.accept = function (visitor) {
        var viz = visitor;
        viz.visitResponses(this);
    };
    /**
     * Returns a single response by status code.
     * @param {string} statusCode
     * @return {OasResponse}
     */
    OasResponses.prototype.getResponse = function (statusCode) {
        if (NodeCompat.equals(statusCode, Constants.PROP_DEFAULT)) {
            return this.default_;
        }
        if (this._responses != null) {
            return /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(this._responses, statusCode);
        }
        return null;
    };
    /**
     * Returns an array of all the responses.
     * @return {OasResponse[]}
     */
    OasResponses.prototype.getResponses = function () {
        var rval = ([]);
        if (this._responses != null) {
            /* 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._responses));
        }
        if (this.default_ != null) {
            /* add */ (rval.push(this.default_) > 0);
        }
        return rval;
    };
    /**
     * Adds a response.
     * @param {string} statusCode
     * @param {OasResponse} response
     * @return {OasResponse}
     */
    OasResponses.prototype.addResponse = function (statusCode, response) {
        if (statusCode == null || NodeCompat.equals(statusCode, Constants.PROP_DEFAULT)) {
            this.default_ = response;
            return response;
        }
        if (this._responses == null) {
            this._responses = ({});
        }
        /* put */ (this._responses[statusCode] = response);
        return response;
    };
    /**
     * Removes a single response child model.
     * @param {string} statusCode
     * @return {OasResponse}
     */
    OasResponses.prototype.removeResponse = function (statusCode) {
        var _this = this;
        if (statusCode == null || NodeCompat.equals(statusCode, Constants.PROP_DEFAULT)) {
            var rval = this.default_;
            this.default_ = null;
            return rval;
        }
        if (this._responses != null) {
            return /* remove */ (function (map) { var deleted = _this._responses[statusCode]; delete _this._responses[statusCode]; return deleted; })(this._responses);
        }
        return null;
    };
    /**
     * Gets a list of all the response status codes.
     * @return {string[]}
     */
    OasResponses.prototype.getResponseStatusCodes = function () {
        var rval = ([]);
        if (this._responses != null) {
            /* addAll */ (function (l1, l2) { return l1.push.apply(l1, l2); })(rval, /* keySet */ Object.keys(this._responses));
        }
        return rval;
    };
    /**
     * Creates a default OAS response.
     * @return {OasResponse}
     */
    OasResponses.prototype.createDefaultResponse = function () {
        return this.createResponse(null);
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#getItem(java.lang.String)
     * @param {string} name
     * @return {OasResponse}
     */
    OasResponses.prototype.getItem = function (name) {
        return this.getResponse(name);
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#getItems()
     * @return {OasResponse[]}
     */
    OasResponses.prototype.getItems = function () {
        return this.getResponses();
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#getItemNames()
     * @return {string[]}
     */
    OasResponses.prototype.getItemNames = function () {
        return this.getResponseStatusCodes();
    };
    OasResponses.prototype.addItem$java_lang_String$io_apicurio_datamodels_openapi_models_OasResponse = 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 {OasResponse} item
     */
    OasResponses.prototype.addItem = function (name, item) {
        if (((typeof name === 'string') || name === null) && ((item != null && item instanceof OasResponse) || item === null)) {
            return this.addItem$java_lang_String$io_apicurio_datamodels_openapi_models_OasResponse(name, item);
        }
        else
            throw new Error('invalid overload');
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#deleteItem(java.lang.String)
     * @param {string} name
     * @return {OasResponse}
     */
    OasResponses.prototype.deleteItem = function (name) {
        return this.removeResponse(name);
    };
    return OasResponses;
}(ExtensibleNode));
export { OasResponses };
OasResponses["__class"] = "io.apicurio.datamodels.openapi.models.OasResponses";
OasResponses["__interfaces"] = ["io.apicurio.datamodels.core.models.IVisitable", "io.apicurio.datamodels.core.models.IIndexedNode"];
import { OasResponse } from './OasResponse';
//# sourceMappingURL=OasResponses.js.map