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 { NodeCompat } from '../../../compat/NodeCompat';
import { Constants } from '../../../core/Constants';
import { DocumentType } from '../../../core/models/DocumentType';
import { Server } from '../../../core/models/common/Server';
import { OasDocument } from '../../models/OasDocument';
/**
 * Constructor.
 * @class
 * @extends OasDocument
 * @author eric.wittmann@gmail.com
 */
var Oas30Document = /** @class */ (function (_super) {
    __extends(Oas30Document, _super);
    function Oas30Document() {
        var _this = _super.call(this) || this;
        if (_this.openapi === undefined)
            _this.openapi = null;
        if (_this.servers === undefined)
            _this.servers = null;
        if (_this.components === undefined)
            _this.components = null;
        _this.openapi = Constants.OPEN_API_30_DEFAULT_VERSION;
        return _this;
    }
    /**
     * @see io.apicurio.datamodels.core.models.Document#getDocumentType()
     * @return {DocumentType}
     */
    Oas30Document.prototype.getDocumentType = function () {
        return DocumentType.openapi3;
    };
    /**
     * @see io.apicurio.datamodels.openapi.models.OasDocument#createPaths()
     * @return {OasPaths}
     */
    Oas30Document.prototype.createPaths = function () {
        var rval = new Oas30Paths();
        rval._ownerDocument = this.ownerDocument();
        rval._parent = this;
        return rval;
    };
    /**
     * @see io.apicurio.datamodels.openapi.models.OasDocument#createSecurityRequirement()
     * @return {OasSecurityRequirement}
     */
    Oas30Document.prototype.createSecurityRequirement = function () {
        var requirement = new Oas30SecurityRequirement();
        requirement._ownerDocument = this;
        requirement._parent = this;
        return requirement;
    };
    /**
     * @see io.apicurio.datamodels.core.models.Document#createInfo()
     * @return {Info}
     */
    Oas30Document.prototype.createInfo = function () {
        var info = new Oas30Info();
        info._ownerDocument = this;
        info._parent = this;
        return info;
    };
    /**
     * @see io.apicurio.datamodels.core.models.Document#createTag()
     * @return {Tag}
     */
    Oas30Document.prototype.createTag = function () {
        var tag = new Oas30Tag();
        tag._ownerDocument = this;
        tag._parent = this;
        return tag;
    };
    /**
     * @see io.apicurio.datamodels.core.models.Document#createExternalDocumentation()
     * @return {ExternalDocumentation}
     */
    Oas30Document.prototype.createExternalDocumentation = function () {
        var ed = new Oas30ExternalDocumentation();
        ed._ownerDocument = this;
        ed._parent = this;
        return ed;
    };
    /**
     * @see io.apicurio.datamodels.core.models.common.IServerParent#createServer()
     * @return {Server}
     */
    Oas30Document.prototype.createServer = function () {
        var rval = new Oas30Server();
        rval._ownerDocument = this;
        rval._parent = this;
        return rval;
    };
    Oas30Document.prototype.addServer$java_lang_String$java_lang_String = function (url, description) {
        var server = this.createServer();
        server.url = url;
        server.description = description;
        if (this.servers == null) {
            this.servers = ([]);
        }
        /* add */ (this.servers.push(server) > 0);
        return server;
    };
    /**
     * Adds a server.
     * @param {string} url
     * @param {string} description
     * @return {Server}
     */
    Oas30Document.prototype.addServer = function (url, description) {
        if (((typeof url === 'string') || url === null) && ((typeof description === 'string') || description === null)) {
            return this.addServer$java_lang_String$java_lang_String(url, description);
        }
        else if (((url != null && url instanceof Server) || url === null) && description === undefined) {
            return this.addServer$io_apicurio_datamodels_core_models_common_Server(url);
        }
        else
            throw new Error('invalid overload');
    };
    /**
     * Creates an OAS 3.0 Components object.
     * @return {Oas30Components}
     */
    Oas30Document.prototype.createComponents = function () {
        var rval = new Oas30Components();
        rval._ownerDocument = this;
        rval._parent = this;
        return rval;
    };
    Oas30Document.prototype.addServer$io_apicurio_datamodels_core_models_common_Server = function (server) {
        if (this.servers == null) {
            this.servers = ([]);
        }
        /* add */ (this.servers.push(server) > 0);
    };
    /**
     * @see io.apicurio.datamodels.core.models.common.IServerParent#getServer(java.lang.String)
     * @param {string} url
     * @return {Server}
     */
    Oas30Document.prototype.getServer = function (url) {
        if (this.servers != null) {
            for (var index199 = 0; index199 < this.servers.length; index199++) {
                var server = this.servers[index199];
                {
                    if (NodeCompat.equals(server.url, url)) {
                        return server;
                    }
                }
            }
        }
        return null;
    };
    /**
     * @see io.apicurio.datamodels.core.models.common.IServerParent#getServers()
     * @return {Server[]}
     */
    Oas30Document.prototype.getServers = function () {
        return this.servers;
    };
    return Oas30Document;
}(OasDocument));
export { Oas30Document };
Oas30Document["__class"] = "io.apicurio.datamodels.openapi.v3.models.Oas30Document";
Oas30Document["__interfaces"] = ["io.apicurio.datamodels.core.models.common.ISecurityRequirementParent", "io.apicurio.datamodels.core.models.IVisitable", "io.apicurio.datamodels.core.models.common.IExternalDocumentationParent", "io.apicurio.datamodels.core.models.common.IServerParent"];
import { Oas30Server } from './Oas30Server';
import { Oas30ExternalDocumentation } from './Oas30ExternalDocumentation';
import { Oas30Tag } from './Oas30Tag';
import { Oas30Info } from './Oas30Info';
import { Oas30SecurityRequirement } from './Oas30SecurityRequirement';
import { Oas30Paths } from './Oas30Paths';
import { Oas30Components } from './Oas30Components';
//# sourceMappingURL=Oas30Document.js.map