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

com.networknt.openapi.parameter.QueryParameterStyle 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 QueryParameterStyle {
	FORM(new FormStyleDeserializer()),
	SPACEDELIMITED(new SpaceDelimitedStyleDeserializer()),
	PIPEDELIMITED(new PipeDelimitedStyleDeserializer()),
	DEEPOBJECT(new DeepObjectStyleDeserializer());
	
	private static Map lookup = new HashMap<>();
	private final StyleParameterDeserializer deserializer;
	
	private QueryParameterStyle(StyleParameterDeserializer deserializer) {
		this.deserializer = deserializer;
	}
	
	static {
		for (QueryParameterStyle style: QueryParameterStyle.values()) {
			lookup.put(style.name(), style);
		}
	}
	
	public static QueryParameterStyle of(String styleStr) {
		if (StringUtils.isBlank(styleStr)) {
			return FORM;
		}
		
		return lookup.get(StringUtils.trimToEmpty(styleStr).toUpperCase());
	}
	
	public static boolean is(String styleStr, QueryParameterStyle style) {
		return style == of(styleStr);
	}
	
	public StyleParameterDeserializer getDeserializer() {
		return this.deserializer;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy