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 { Node } from './Node';
/**
 * All data models that can be extended using the "x-*" approach to adding vendor extension
 * properties must extend this class.
 * @author eric.wittmann@gmail.com
 * @class
 * @extends Node
 */
var ExtensibleNode = /** @class */ (function (_super) {
    __extends(ExtensibleNode, _super);
    function ExtensibleNode() {
        var _this = _super.call(this) || this;
        if (_this._extensions === undefined)
            _this._extensions = null;
        return _this;
    }
    /**
     * @see io.apicurio.datamodels.core.models.Node#isExtensible()
     * @return {boolean}
     */
    ExtensibleNode.prototype.isExtensible = function () {
        return true;
    };
    /**
     * Called to create an extension child.
     * @return {Extension}
     */
    ExtensibleNode.prototype.createExtension = function () {
        var extension = new Extension();
        extension._ownerDocument = this.ownerDocument();
        extension._parent = this;
        return extension;
    };
    /**
     * Called to add a named extension to this node.
     * @param {string} name
     * @param {Extension} extension
     */
    ExtensibleNode.prototype.addExtension = function (name, extension) {
        if (this._extensions == null) {
            this._extensions = ({});
        }
        /* put */ (this._extensions[name] = extension);
    };
    /**
     * Returns all of the extensions defined on this node.
     * @return {Extension[]}
     */
    ExtensibleNode.prototype.getExtensions = function () {
        if (this._extensions != null) {
            return ( /* values */(function (obj) { return Object.keys(obj).map(function (key) { return obj[key]; }); })(this._extensions).slice(0));
        }
        else {
            return null;
        }
    };
    /**
     * Gets a single extension by name.
     * @param {string} name
     * @return {Extension}
     */
    ExtensibleNode.prototype.getExtension = function (name) {
        var rval = null;
        if (this._extensions != null) {
            rval = /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(this._extensions, name);
        }
        return rval;
    };
    /**
     * Removes a single extension by name.
     * @param {string} name
     */
    ExtensibleNode.prototype.removeExtension = function (name) {
        var _this = this;
        if (this._extensions != null) {
            /* remove */ (function (map) { var deleted = _this._extensions[name]; delete _this._extensions[name]; return deleted; })(this._extensions);
        }
    };
    /**
     * Removes all extensions from this node.
     */
    ExtensibleNode.prototype.clearExtensions = function () {
        if (this._extensions != null) {
            /* clear */ (function (obj) { for (var member in obj)
                delete obj[member]; })(this._extensions);
        }
    };
    return ExtensibleNode;
}(Node));
export { ExtensibleNode };
ExtensibleNode["__class"] = "io.apicurio.datamodels.core.models.ExtensibleNode";
ExtensibleNode["__interfaces"] = ["io.apicurio.datamodels.core.models.IVisitable"];
import { Extension } from './Extension';
//# sourceMappingURL=ExtensibleNode.js.map