org.eclipse.microprofile.openapi.models.servers.ServerVariables Maven / Gradle / Ivy
Show all versions of microprofile-openapi-api Show documentation
/**
* Copyright (c) 2017 Contributors to the Eclipse Foundation
* Copyright 2017 SmartBear Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.microprofile.openapi.models.servers;
import java.util.Map;
import org.eclipse.microprofile.openapi.models.Constructible;
import org.eclipse.microprofile.openapi.models.Extensible;
/**
* ServerVariables
*
* @see ServerVariable Object
*/
public interface ServerVariables extends Constructible, Extensible {
/**
* This method adds a key-value item to a ServerVariables instance from the name-item parameter pair and returns the modified instance.
*
* @param name the name of ServerVariable instance
* @param serverVariable the ServerVariable instance
* @return ServerVariables instance with the added name-item pair.
*/
ServerVariables addServerVariable(String name, ServerVariable serverVariable);
/**
* Removes the given server variables.
*
* @param name the name of ServerVariable instance
*/
void removeServerVariable(String name);
/**
* Returns a copy map (potentially immutable) of the server variables.
*
* @return all items
*/
Map getServerVariables();
/**
* Set the server variables map to this ServerVariables object.
*
* @param items a map containing key-value item.
*/
void setServerVariables(Map items);
/**
* Check whether a server variable is present in the map. This is a convenience method for getServerVariables().containsKey(name)
*
* @param name the name of ServerVariable instance
* @return a boolean to indicate if the server variable is present or not.
*/
default boolean hasServerVariable(String name) {
Map map = getServerVariables();
if (map == null) {
return false;
}
return map.containsKey(name);
}
/**
* Returns a server variable for a given name. This is a convenience method for getServerVariables().get(name)
*
* @param name the name of ServerVariable instance
* @return the corresponding server variable or null.
*/
default ServerVariable getServerVariable(String name) {
Map map = getServerVariables();
if (map == null) {
return null;
}
return map.get(name);
}
}