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 { AaiChannelBindings } from '../../../asyncapi/models/AaiChannelBindings';
import { AaiCorrelationId } from '../../../asyncapi/models/AaiCorrelationId';
import { AaiMessageBindings } from '../../../asyncapi/models/AaiMessageBindings';
import { AaiMessageTrait } from '../../../asyncapi/models/AaiMessageTrait';
import { AaiOperationBindings } from '../../../asyncapi/models/AaiOperationBindings';
import { AaiOperationTrait } from '../../../asyncapi/models/AaiOperationTrait';
import { AaiParameter } from '../../../asyncapi/models/AaiParameter';
import { AaiSecurityScheme } from '../../../asyncapi/models/AaiSecurityScheme';
import { AaiServerBindings } from '../../../asyncapi/models/AaiServerBindings';
import { Aai20ChannelBindingsDefinition } from '../../../asyncapi/v2/models/Aai20ChannelBindingsDefinition';
import { Aai20CorrelationId } from '../../../asyncapi/v2/models/Aai20CorrelationId';
import { Aai20Document } from '../../../asyncapi/v2/models/Aai20Document';
import { Aai20Message } from '../../../asyncapi/v2/models/Aai20Message';
import { Aai20MessageBindingsDefinition } from '../../../asyncapi/v2/models/Aai20MessageBindingsDefinition';
import { Aai20MessageTraitDefinition } from '../../../asyncapi/v2/models/Aai20MessageTraitDefinition';
import { Aai20OperationBindingsDefinition } from '../../../asyncapi/v2/models/Aai20OperationBindingsDefinition';
import { Aai20OperationTraitDefinition } from '../../../asyncapi/v2/models/Aai20OperationTraitDefinition';
import { Aai20Parameter } from '../../../asyncapi/v2/models/Aai20Parameter';
import { Aai20SecurityScheme } from '../../../asyncapi/v2/models/Aai20SecurityScheme';
import { Aai20ServerBindingsDefinition } from '../../../asyncapi/v2/models/Aai20ServerBindingsDefinition';
import { AbstractReferenceLocalizationStrategy } from './AbstractReferenceLocalizationStrategy';
var Aai20IReferenceManipulationStrategy = /** @class */ (function (_super) {
    __extends(Aai20IReferenceManipulationStrategy, _super);
    function Aai20IReferenceManipulationStrategy() {
        return _super.call(this) || this;
    }
    /**
     *
     * @param {Document} document
     * @param {string} name
     * @param {Node} component
     * @return {IReferenceManipulationStrategy.ReferenceAndNode}
     */
    Aai20IReferenceManipulationStrategy.prototype.attachAsDefinition = function (document, name, component) {
        if (!(document != null && document instanceof Aai20Document))
            throw Object.defineProperty(new Error("Aai20Document expected."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.IllegalArgumentException', 'java.lang.Exception'] });
        var model = document;
        if (model.components == null)
            model.components = model.createComponents();
        if (component != null && component instanceof Aai20Message) {
            if (model.components.messages != null && /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(model.components.messages, name) != null)
                throw Object.defineProperty(new Error("Definition with that name already exists: " + name), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.IllegalArgumentException', 'java.lang.Exception'] });
            var definition = (this.wrap(component, new Aai20Message(name), model));
            definition.attachToParent(model.components);
            model.components.addMessage(definition.getName(), definition);
            return new IReferenceManipulationStrategy.ReferenceAndNode(this.PREFIX + "messages/" + name, definition);
        }
        if (component != null && component instanceof AaiSecurityScheme) {
            if (model.components.securitySchemes != null && /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(model.components.securitySchemes, name) != null)
                throw Object.defineProperty(new Error("Definition with that name already exists: " + name), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.IllegalArgumentException', 'java.lang.Exception'] });
            var definition = (this.wrap(component, new Aai20SecurityScheme(name), model));
            definition.attachToParent(model.components);
            model.components.addSecurityScheme(definition.getName(), definition);
            return new IReferenceManipulationStrategy.ReferenceAndNode(this.PREFIX + "securitySchemes/" + name, definition);
        }
        if (component != null && component instanceof AaiParameter) {
            if (model.components.parameters != null && /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(model.components.parameters, name) != null)
                throw Object.defineProperty(new Error("Definition with that name already exists: " + name), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.IllegalArgumentException', 'java.lang.Exception'] });
            var definition = (this.wrap(component, new Aai20Parameter(name), model));
            definition.attachToParent(model.components);
            model.components.addParameter(definition.getName(), definition);
            return new IReferenceManipulationStrategy.ReferenceAndNode(this.PREFIX + "parameters/" + name, definition);
        }
        if (component != null && component instanceof AaiCorrelationId) {
            if (model.components.correlationIds != null && /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(model.components.correlationIds, name) != null)
                throw Object.defineProperty(new Error("Definition with that name already exists: " + name), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.IllegalArgumentException', 'java.lang.Exception'] });
            var definition = (this.wrap(component, new Aai20CorrelationId(name), model));
            definition.attachToParent(model.components);
            model.components.addCorrelationId(definition.getName(), definition);
            return new IReferenceManipulationStrategy.ReferenceAndNode(this.PREFIX + "correlationIds/" + name, definition);
        }
        if (component != null && component instanceof AaiOperationTrait) {
            if (model.components.operationTraits != null && /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(model.components.operationTraits, name) != null)
                throw Object.defineProperty(new Error("Definition with that name already exists: " + name), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.IllegalArgumentException', 'java.lang.Exception'] });
            var definition = (this.wrap(component, new Aai20OperationTraitDefinition(name), model));
            definition.attachToParent(model.components);
            model.components.addOperationTraitDefinition(definition.getName(), definition);
            return new IReferenceManipulationStrategy.ReferenceAndNode(this.PREFIX + "operationTraits/" + name, definition);
        }
        if (component != null && component instanceof AaiMessageTrait) {
            if (model.components.messageTraits != null && /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(model.components.messageTraits, name) != null)
                throw Object.defineProperty(new Error("Definition with that name already exists: " + name), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.IllegalArgumentException', 'java.lang.Exception'] });
            var definition = (this.wrap(component, new Aai20MessageTraitDefinition(name), model));
            definition.attachToParent(model.components);
            model.components.addMessageTraitDefinition(definition.getName(), definition);
            return new IReferenceManipulationStrategy.ReferenceAndNode(this.PREFIX + "messageTraits/" + name, definition);
        }
        if (component != null && component instanceof AaiServerBindings) {
            if (model.components.serverBindings != null && /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(model.components.serverBindings, name) != null)
                throw Object.defineProperty(new Error("Definition with that name already exists: " + name), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.IllegalArgumentException', 'java.lang.Exception'] });
            var definition = (this.wrap(component, new Aai20ServerBindingsDefinition(name), model));
            definition.attachToParent(model.components);
            model.components.addServerBindingDefinition(definition.getName(), definition);
            return new IReferenceManipulationStrategy.ReferenceAndNode(this.PREFIX + "serverBindings/" + name, definition);
        }
        if (component != null && component instanceof AaiChannelBindings) {
            if (model.components.channelBindings != null && /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(model.components.channelBindings, name) != null)
                throw Object.defineProperty(new Error("Definition with that name already exists: " + name), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.IllegalArgumentException', 'java.lang.Exception'] });
            var definition = (this.wrap(component, new Aai20ChannelBindingsDefinition(name), model));
            definition.attachToParent(model.components);
            model.components.addChannelBindingDefinition(definition.getName(), definition);
            return new IReferenceManipulationStrategy.ReferenceAndNode(this.PREFIX + "channelBindings/" + name, definition);
        }
        if (component != null && component instanceof AaiOperationBindings) {
            if (model.components.operationBindings != null && /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(model.components.operationBindings, name) != null)
                throw Object.defineProperty(new Error("Definition with that name already exists: " + name), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.IllegalArgumentException', 'java.lang.Exception'] });
            var definition = (this.wrap(component, new Aai20OperationBindingsDefinition(name), model));
            definition.attachToParent(model.components);
            model.components.addOperationBindingDefinition(definition.getName(), definition);
            return new IReferenceManipulationStrategy.ReferenceAndNode(this.PREFIX + "operationBindings/" + name, definition);
        }
        if (component != null && component instanceof AaiMessageBindings) {
            if (model.components.messageBindings != null && /* get */ (function (m, k) { return m[k] === undefined ? null : m[k]; })(model.components.messageBindings, name) != null)
                throw Object.defineProperty(new Error("Definition with that name already exists: " + name), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.IllegalArgumentException', 'java.lang.Exception'] });
            var definition = (this.wrap(component, new Aai20MessageBindingsDefinition(name), model));
            definition.attachToParent(model.components);
            model.components.addMessageBindingDefinition(definition.getName(), definition);
            return new IReferenceManipulationStrategy.ReferenceAndNode(this.PREFIX + "messageBindings/" + name, definition);
        }
        return null;
    };
    /**
     *
     * @param {Document} document
     * @return {*}
     */
    Aai20IReferenceManipulationStrategy.prototype.getExistingLocalComponents = function (document) {
        var _this = this;
        if (!(document != null && document instanceof Aai20Document))
            throw Object.defineProperty(new Error("Aai20Document expected."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.IllegalArgumentException', 'java.lang.Exception'] });
        var model = document;
        var res = ({});
        if (model.components != null) {
            this.transform(model.components.messages, function (name) { return _this.PREFIX + "messages/" + name; }, res);
            this.transform(model.components.securitySchemes, function (name) { return _this.PREFIX + "securitySchemes/" + name; }, res);
            this.transform(model.components.parameters, function (name) { return _this.PREFIX + "parameters/" + name; }, res);
            this.transform(model.components.correlationIds, function (name) { return _this.PREFIX + "correlationIds/" + name; }, res);
            this.transform(model.components.operationTraits, function (name) { return _this.PREFIX + "operationTraits/" + name; }, res);
            this.transform(model.components.messageTraits, function (name) { return _this.PREFIX + "messageTraits/" + name; }, res);
            this.transform(model.components.serverBindings, function (name) { return _this.PREFIX + "serverBindings/" + name; }, res);
            this.transform(model.components.channelBindings, function (name) { return _this.PREFIX + "channelBindings/" + name; }, res);
            this.transform(model.components.operationBindings, function (name) { return _this.PREFIX + "operationBindings/" + name; }, res);
            this.transform(model.components.messageBindings, function (name) { return _this.PREFIX + "messageBindings/" + name; }, res);
            {
                var array183 = /* keySet */ Object.keys(model.components.schemas);
                for (var index182 = 0; index182 < array183.length; index182++) {
                    var name_1 = array183[index182];
                    {
                        /* put */ (res[this.PREFIX + "schemas/" + name_1] = null);
                    }
                }
            }
        }
        return res;
    };
    return Aai20IReferenceManipulationStrategy;
}(AbstractReferenceLocalizationStrategy));
export { Aai20IReferenceManipulationStrategy };
Aai20IReferenceManipulationStrategy["__class"] = "io.apicurio.datamodels.openapi.visitors.dereference.Aai20IReferenceManipulationStrategy";
Aai20IReferenceManipulationStrategy["__interfaces"] = ["io.apicurio.datamodels.openapi.visitors.dereference.IReferenceManipulationStrategy"];
import { IReferenceManipulationStrategy } from './IReferenceManipulationStrategy';
//# sourceMappingURL=Aai20IReferenceManipulationStrategy.js.map