io.swagger.jaxrs.config.SwaggerConfigLocator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swagger-all Show documentation
Show all versions of swagger-all Show documentation
swagger-all is a rebundled verison of Swagger as one OSGi bundle.
The newest version!
package io.swagger.jaxrs.config;
import io.swagger.config.SwaggerConfig;
import io.swagger.models.Swagger;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
public class SwaggerConfigLocator {
private static SwaggerConfigLocator instance;
private ConcurrentMap configMap = new ConcurrentHashMap();
private ConcurrentMap swaggerMap = new ConcurrentHashMap();
public static SwaggerConfigLocator getInstance() {
if (instance == null) {
instance = new SwaggerConfigLocator();
}
return instance;
}
private SwaggerConfigLocator() {
}
public SwaggerConfig getConfig(String id) {
SwaggerConfig value = configMap.get(id);
if (value != null) {
return value;
}
return new SwaggerConfig() {
@Override
public Swagger configure(Swagger swagger) {
return swagger;
}
@Override
public String getFilterClass() {
return null;
}
};
}
public void putConfig(String id, SwaggerConfig config) {
if (! configMap.containsKey(id)) configMap.put(id, config);
}
public Swagger getSwagger(String id) {
Swagger value = swaggerMap.get(id);
if (value != null) {
return value;
}
return new Swagger();
}
public void putSwagger(String id, Swagger swagger) {
if (! swaggerMap.containsKey(id)) swaggerMap.put(id, swagger);
}
}