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 { ExtensibleNode } from '../../../core/models/ExtensibleNode';
/**
 * Constructor.
 * @param {string} name
 * @class
 * @extends ExtensibleNode
 * @author eric.wittmann@gmail.com
 */
var Oas30MediaType = /** @class */ (function (_super) {
    __extends(Oas30MediaType, _super);
    function Oas30MediaType(name) {
        var _this = _super.call(this) || this;
        if (_this._name === undefined)
            _this._name = null;
        if (_this.schema === undefined)
            _this.schema = null;
        if (_this.example === undefined)
            _this.example = null;
        _this.examples = ({});
        _this.encoding = ({});
        _this._name = name;
        return _this;
    }
    /**
     * @see io.apicurio.datamodels.core.models.common.INamed#getName()
     * @return {string}
     */
    Oas30MediaType.prototype.getName = function () {
        return this._name;
    };
    /**
     * @see io.apicurio.datamodels.core.models.common.INamed#rename(java.lang.String)
     * @param {string} newName
     */
    Oas30MediaType.prototype.rename = function (newName) {
        this._name = newName;
    };
    /**
     * @see io.apicurio.datamodels.core.models.Node#accept(io.apicurio.datamodels.core.visitors.IVisitor)
     * @param {*} visitor
     */
    Oas30MediaType.prototype.accept = function (visitor) {
        var viz = visitor;
        viz.visitMediaType(this);
    };
    /**
     * Creates a child schema model.
     * @return {Oas30Schema}
     */
    Oas30MediaType.prototype.createSchema = function () {
        var rval = new Oas30Schema();
        rval._ownerDocument = this.ownerDocument();
        rval._parent = this;
        return rval;
    };
    /**
     * Creates a encoding.
     * @param {string} name
     * @return {Oas30Encoding}
     */
    Oas30MediaType.prototype.createEncoding = function (name) {
        var rval = new Oas30Encoding(name);
        rval._ownerDocument = this.ownerDocument();
        rval._parent = this;
        return rval;
    };
    /**
     * Adds a encoding.
     * @param {string} name
     * @param {Oas30Encoding} encoding
     */
    Oas30MediaType.prototype.addEncoding = function (name, encoding) {
        /* put */ (this.encoding[name] = encoding);
    };
    /**
     * Gets a single encoding by name.
     * @param {string} name
     * @return {Oas30Encoding}
     */
    Oas30MediaType.prototype.getEncoding = function (name) {
        return /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(this.encoding, name);
    };
    /**
     * Removes a single encoding and returns it.  This may return null or undefined if none found.
     * @param {string} name
     * @return {Oas30Encoding}
     */
    Oas30MediaType.prototype.removeEncoding = function (name) {
        var _this = this;
        return /* remove */ (function (map) { var deleted = _this.encoding[name]; delete _this.encoding[name]; return deleted; })(this.encoding);
    };
    /**
     * Gets a list of all encodings.
     * @return {Oas30Encoding[]}
     */
    Oas30MediaType.prototype.getEncodings = 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.encoding));
        return rval;
    };
    /**
     * Creates a child Example model.
     * @param {string} name
     * @return {Oas30Example}
     */
    Oas30MediaType.prototype.createExample = function (name) {
        var rval = new Oas30Example(name);
        rval._ownerDocument = this.ownerDocument();
        rval._parent = this;
        return rval;
    };
    /**
     * Adds the Example to the map of examples.
     * @param {Oas30Example} example
     */
    Oas30MediaType.prototype.addExample = function (example) {
        /* put */ (this.examples[example.getName()] = example);
    };
    /**
     * Removes an Example and returns it.
     * @param {string} name
     * @return {Oas30Example}
     */
    Oas30MediaType.prototype.removeExample = function (name) {
        var _this = this;
        return /* remove */ (function (map) { var deleted = _this.examples[name]; delete _this.examples[name]; return deleted; })(this.examples);
    };
    /**
     * Gets a single example by name.
     * @param {string} name
     * @return {Oas30Example}
     */
    Oas30MediaType.prototype.getExample = function (name) {
        return /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(this.examples, name);
    };
    /**
     * Gets all examples.
     * @return {Oas30Example[]}
     */
    Oas30MediaType.prototype.getExamples = 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.examples));
        return rval;
    };
    return Oas30MediaType;
}(ExtensibleNode));
export { Oas30MediaType };
Oas30MediaType["__class"] = "io.apicurio.datamodels.openapi.v3.models.Oas30MediaType";
Oas30MediaType["__interfaces"] = ["io.apicurio.datamodels.core.models.common.IExampleParent", "io.apicurio.datamodels.core.models.IVisitable", "io.apicurio.datamodels.core.models.common.INamed"];
import { Oas30Encoding } from './Oas30Encoding';
import { Oas30Example } from './Oas30Example';
import { Oas30Schema } from './Oas30Schema';
//# sourceMappingURL=Oas30MediaType.js.map