All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.networknt.oas.model.impl.ServerImpl Maven / Gradle / Ivy

There is a newer version: 2.1.38
Show newest version
package com.networknt.oas.model.impl;

import com.fasterxml.jackson.databind.JsonNode;
import com.networknt.oas.jsonoverlay.*;
import com.networknt.oas.model.OpenApi3;
import com.networknt.oas.model.Server;
import com.networknt.oas.model.ServerVariable;

import java.util.Map;

public class ServerImpl extends OpenApiObjectImpl implements Server {


    public ServerImpl(JsonNode json, JsonOverlay parent, ReferenceRegistry refReg) {
        super(json, parent, refReg);
        super.maybeElaborateChildrenAtCreation();
    }


    public ServerImpl(Server server, JsonOverlay parent, ReferenceRegistry refReg) {
        super(server, parent, refReg);
        super.maybeElaborateChildrenAtCreation();
    }


    private ChildOverlay url = null;


    private ChildOverlay description = null;


    private ChildMapOverlay serverVariables = null;


    private ChildMapOverlay variablesExtensions = null;


    private ChildMapOverlay extensions = null;

    // Url
    @Override
    public String getUrl() {
        return url.get();
    }

    @Override
    public String getUrl(boolean elaborate) {
        return url.get(elaborate);
    }

    @Override
    public void setUrl(String url) {
        this.url.set(url);
    }

    // Description
    @Override
    public String getDescription() {
        return description.get();
    }

    @Override
    public String getDescription(boolean elaborate) {
        return description.get(elaborate);
    }

    @Override
    public void setDescription(String description) {
        this.description.set(description);
    }

    // ServerVariable
    @Override
    public Map getServerVariables() {
        return serverVariables.get();
    }

    @Override
    public Map getServerVariables(boolean elaborate) {
        return serverVariables.get(elaborate);
    }

    @Override
    public boolean hasServerVariable(String name) {
        return serverVariables.containsKey(name);
    }

    @Override
    public ServerVariable getServerVariable(String name) {
        return serverVariables.get(name);
    }

    @Override
    public void setServerVariables(Map serverVariables) {
        this.serverVariables.set(serverVariables);
    }

    @Override
    public void setServerVariable(String name, ServerVariable serverVariable) {
        serverVariables.set(name, serverVariable);
    }

    @Override
    public void removeServerVariable(String name) {
        serverVariables.remove(name);
    }

    // VariablesExtension
    @Override
    public Map getVariablesExtensions() {
        return variablesExtensions.get();
    }

    @Override
    public Map getVariablesExtensions(boolean elaborate) {
        return variablesExtensions.get(elaborate);
    }

    @Override
    public boolean hasVariablesExtension(String name) {
        return variablesExtensions.containsKey(name);
    }

    @Override
    public Object getVariablesExtension(String name) {
        return variablesExtensions.get(name);
    }

    @Override
    public void setVariablesExtensions(Map variablesExtensions) {
        this.variablesExtensions.set(variablesExtensions);
    }

    @Override
    public void setVariablesExtension(String name, Object variablesExtension) {
        variablesExtensions.set(name, variablesExtension);
    }

    @Override
    public void removeVariablesExtension(String name) {
        variablesExtensions.remove(name);
    }

    // Extension
    @Override
    public Map getExtensions() {
        return extensions.get();
    }

    @Override
    public Map getExtensions(boolean elaborate) {
        return extensions.get(elaborate);
    }

    @Override
    public boolean hasExtension(String name) {
        return extensions.containsKey(name);
    }

    @Override
    public Object getExtension(String name) {
        return extensions.get(name);
    }

    @Override
    public void setExtensions(Map extensions) {
        this.extensions.set(extensions);
    }

    @Override
    public void setExtension(String name, Object extension) {
        extensions.set(name, extension);
    }

    @Override
    public void removeExtension(String name) {
        extensions.remove(name);
    }

    @Override
    protected void elaborateChildren() {
        url = createChild("url", this, StringOverlay.factory);
        description = createChild("description", this, StringOverlay.factory);
        serverVariables = createChildMap("variables", this, ServerVariableImpl.factory, "(?!x-)[a-zA-Z0-9\\._-]+");
        variablesExtensions = createChildMap("variables", this, ObjectOverlay.factory, "x-.+");
        extensions = createChildMap("", this, ObjectOverlay.factory, "x-.+");
    }


    public static OverlayFactory factory = new OverlayFactory() {
        @Override
        protected Class getOverlayClass() {
            return ServerImpl.class;
        }

        @Override
        public ServerImpl _create(Server server, JsonOverlay parent, ReferenceRegistry refReg) {
            return new ServerImpl(server, parent, refReg);
        }

        @Override
        public ServerImpl _create(JsonNode json, JsonOverlay parent, ReferenceRegistry refReg) {
            return new ServerImpl(json, parent, refReg);
        }
    };

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy