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

com.networknt.openapi.parameter.PathParameterStyle Maven / Gradle / Ivy

Go to download

An OpenAPI Specification 3.0 meta handler module that cache the spec and attached context related operation to the request based on uri and method.

There is a newer version: 2.1.37
Show newest version
package com.networknt.openapi.parameter;

import java.util.HashMap;
import java.util.Map;

import com.networknt.utility.StringUtils;

public enum PathParameterStyle {
	SIMPLE(new SimpleStyleDeserializer()),
	LABEL(new LabelStyleDeserializer()),
	MATRIX(new MatrixStyleDeserializer());
	
	private static Map lookup = new HashMap<>();
	private final StyleParameterDeserializer deserializer;
	
	private PathParameterStyle(StyleParameterDeserializer deserializer) {
		this.deserializer = deserializer;
	}
	
	static {
		for (PathParameterStyle style: PathParameterStyle.values()) {
			lookup.put(style.name(), style);
		}
	}
	
	public static PathParameterStyle of(String styleStr) {
		if (StringUtils.isBlank(styleStr)) {
			return SIMPLE;
		}
		
		return lookup.get(StringUtils.trimToEmpty(styleStr).toUpperCase());
	}
	
	public static boolean is(String styleStr, PathParameterStyle style) {
		return style == of(styleStr);
	}
	
	public StyleParameterDeserializer getDeserializer() {
		return this.deserializer;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy