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';
import { AaiMessageBase } from './AaiMessageBase';
/**
 * Constructor.
 * @param {Node} parent
 * @param {string} name
 * @class
 * @extends AaiMessageBase
 * @author Jakub Senko <jsenko@redhat.com>
 */
var AaiMessage = /** @class */ (function (_super) {
    __extends(AaiMessage, _super);
    function AaiMessage(parent, name) {
        var _this = this;
        if (((parent != null && parent instanceof Node) || parent === null) && ((typeof name === 'string') || name === null)) {
            var __args = arguments;
            _this = _super.call(this, parent, name) || this;
            if (_this.oneOf === undefined)
                _this.oneOf = null;
            if (_this.payload === undefined)
                _this.payload = null;
            if (_this.traits === undefined)
                _this.traits = null;
            _this._isOneOfMessage = false;
            if (_this.oneOf === undefined)
                _this.oneOf = null;
            if (_this.payload === undefined)
                _this.payload = null;
            if (_this.traits === undefined)
                _this.traits = null;
        }
        else if (((typeof parent === 'string') || parent === null) && name === undefined) {
            var __args = arguments;
            var name_1 = __args[0];
            _this = _super.call(this, name_1) || this;
            if (_this.oneOf === undefined)
                _this.oneOf = null;
            if (_this.payload === undefined)
                _this.payload = null;
            if (_this.traits === undefined)
                _this.traits = null;
            _this._isOneOfMessage = false;
            if (_this.oneOf === undefined)
                _this.oneOf = null;
            if (_this.payload === undefined)
                _this.payload = null;
            if (_this.traits === undefined)
                _this.traits = null;
        }
        else if (((parent != null && parent instanceof Node) || parent === null) && name === undefined) {
            var __args = arguments;
            _this = _super.call(this, parent) || this;
            if (_this.oneOf === undefined)
                _this.oneOf = null;
            if (_this.payload === undefined)
                _this.payload = null;
            if (_this.traits === undefined)
                _this.traits = null;
            _this._isOneOfMessage = false;
            if (_this.oneOf === undefined)
                _this.oneOf = null;
            if (_this.payload === undefined)
                _this.payload = null;
            if (_this.traits === undefined)
                _this.traits = null;
        }
        else
            throw new Error('invalid overload');
        return _this;
    }
    /**
     * @see io.apicurio.datamodels.core.models.Node#accept(io.apicurio.datamodels.core.visitors.IVisitor)
     * @param {*} visitor
     */
    AaiMessage.prototype.accept = function (visitor) {
        var v = visitor;
        v.visitMessage(this);
    };
    /**
     * Add a oneOf message.
     * @param {AaiMessage} item
     */
    AaiMessage.prototype.addOneOfMessage = function (item) {
        if (this.oneOf == null)
            this.oneOf = ([]);
        /* add */ (this.oneOf.push(item) > 0);
    };
    /**
     * @see io.apicurio.datamodels.asyncapi.models.AaiMessageBase#addTag(io.apicurio.datamodels.asyncapi.models.AaiTag)
     * @param {AaiTag} tag
     */
    AaiMessage.prototype.addTag = function (tag) {
        if (this.tags == null)
            this.tags = ([]);
        /* add */ (this.tags.push(tag) > 0);
    };
    /**
     * @param {AaiMessageTrait} traitModel
     */
    AaiMessage.prototype.addTrait = function (traitModel) {
        if (this.traits == null) {
            this.traits = ([]);
        }
        /* add */ (this.traits.push(traitModel) > 0);
    };
    return AaiMessage;
}(AaiMessageBase));
export { AaiMessage };
AaiMessage["__class"] = "io.apicurio.datamodels.asyncapi.models.AaiMessage";
AaiMessage["__interfaces"] = ["io.apicurio.datamodels.core.models.IVisitable", "io.apicurio.datamodels.core.models.IReferenceNode", "io.apicurio.datamodels.core.models.common.INamed"];
//# sourceMappingURL=AaiMessage.js.map