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 Oas20Definitions = /** @class */ (function (_super) {
    __extends(Oas20Definitions, _super);
    function Oas20Definitions() {
        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
     */
    Oas20Definitions.prototype.accept = function (visitor) {
        var viz = visitor;
        viz.visitDefinitions(this);
    };
    /**
     * Returns a single definition schema by name.
     * @param {string} name
     * @return {Oas20SchemaDefinition}
     */
    Oas20Definitions.prototype.getDefinition = function (name) {
        return /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(this.items, name);
    };
    /**
     * Returns an array of all the definitions.
     * @return {Oas20SchemaDefinition[]}
     */
    Oas20Definitions.prototype.getDefinitions = 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 definition.
     * @param {string} name
     * @param {Oas20SchemaDefinition} schema
     * @return {Oas20SchemaDefinition}
     */
    Oas20Definitions.prototype.addDefinition = function (name, schema) {
        /* put */ (this.items[name] = schema);
        return schema;
    };
    /**
     * Removes a definition by name.
     * @param {string} name
     * @return {Oas20SchemaDefinition}
     */
    Oas20Definitions.prototype.removeDefinition = 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 definition names.
     * @return {string[]}
     */
    Oas20Definitions.prototype.getDefinitionNames = 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 Schema object.
     * @param {string} name
     * @return {Oas20SchemaDefinition}
     */
    Oas20Definitions.prototype.createSchemaDefinition = function (name) {
        var rval = new Oas20SchemaDefinition(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 {Oas20SchemaDefinition}
     */
    Oas20Definitions.prototype.getItem = function (name) {
        return this.getDefinition(name);
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#getItems()
     * @return {Oas20SchemaDefinition[]}
     */
    Oas20Definitions.prototype.getItems = function () {
        return this.getDefinitions();
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#getItemNames()
     * @return {string[]}
     */
    Oas20Definitions.prototype.getItemNames = function () {
        return this.getDefinitionNames();
    };
    Oas20Definitions.prototype.addItem$java_lang_String$io_apicurio_datamodels_openapi_v2_models_Oas20SchemaDefinition = function (name, item) {
        this.addDefinition(name, item);
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#addItem(java.lang.String, io.apicurio.datamodels.core.models.Node)
     * @param {string} name
     * @param {Oas20SchemaDefinition} item
     */
    Oas20Definitions.prototype.addItem = function (name, item) {
        if (((typeof name === 'string') || name === null) && ((item != null && item instanceof Oas20SchemaDefinition) || item === null)) {
            return this.addItem$java_lang_String$io_apicurio_datamodels_openapi_v2_models_Oas20SchemaDefinition(name, item);
        }
        else
            throw new Error('invalid overload');
    };
    /**
     * @see io.apicurio.datamodels.core.models.IIndexedNode#deleteItem(java.lang.String)
     * @param {string} name
     * @return {Oas20SchemaDefinition}
     */
    Oas20Definitions.prototype.deleteItem = function (name) {
        return this.removeDefinition(name);
    };
    return Oas20Definitions;
}(Node));
export { Oas20Definitions };
Oas20Definitions["__class"] = "io.apicurio.datamodels.openapi.v2.models.Oas20Definitions";
Oas20Definitions["__interfaces"] = ["io.apicurio.datamodels.core.models.IVisitable", "io.apicurio.datamodels.core.models.IIndexedNode"];
import { Oas20SchemaDefinition } from './Oas20SchemaDefinition';
//# sourceMappingURL=Oas20Definitions.js.map