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

com.jd.httpservice.agent.RequestParamMapDefinition Maven / Gradle / Ivy

There is a newer version: 2.1.4.RELEASE
Show newest version
package com.jd.httpservice.agent;

import java.util.LinkedList;
import java.util.List;

import org.springframework.util.StringUtils;

import com.jd.httpservice.PropertiesConverter;
import com.jd.httpservice.RequestParamMap;

class RequestParamMapDefinition {
	
	private String prefix;
	
	private boolean required;
	
	private PropertiesConverter converter;
	
	public RequestParamMapDefinition(String prefix, String seperator, boolean required, PropertiesConverter converter) {
		if (prefix == null || prefix.length() ==0) {
			this.prefix = "";
		}else{
			this.prefix = prefix + seperator;
		}
		this.required = required;
		this.converter = converter;
	}

	public boolean isRequired() {
		return required;
	}

	public PropertiesConverter getConverter() {
		return converter;
	}

	public String getPrefix() {
		return prefix;
	}
	
	
	public static List>  resolveParamMapDefinitions(List> reqParamAnnos){
		List> reqDefs = new LinkedList>();
		for (ArgDefEntry entry : reqParamAnnos) {
			RequestParamMap reqParamAnno = entry.getDefinition();
			String prefix = StringUtils.trimWhitespace(reqParamAnno.prefix());
			String seperator = StringUtils.trimWhitespace(reqParamAnno.seperator());
			
			Class converterClazz = reqParamAnno.converter();
			PropertiesConverter converter = PropertiesConverterFactory.instantiatePropertiesConverter(converterClazz, entry.getArgType());
			RequestParamMapDefinition reqDef = new RequestParamMapDefinition(prefix, seperator, reqParamAnno.required(),converter);
			reqDefs.add(new ArgDefEntry(entry.getIndex(), entry.getArgType(), reqDef));
		}
		return reqDefs;
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy