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

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

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

import org.springframework.beans.BeanUtils;

import com.jd.httpservice.PropertiesConverter;
import com.jd.httpservice.StringConverter;

public class PropertiesConverterFactory {
	
	public static PropertiesConverter instantiatePropertiesConverter(Class converterClazz, Class argType){
		if (converterClazz == null || PropertiesConverter.class == converterClazz || PojoPropertiesConverter.class == converterClazz) {
			return new PojoPropertiesConverter(argType);
		}
		if (!PropertiesConverter.class.isAssignableFrom(converterClazz)) {
			throw new IllegalHttpServiceDefinitionException(
					"The specified converter of path param doesn't implement the interface "
							+ StringConverter.class.getName() + "!");
		}
		
		PropertiesConverter converter = (PropertiesConverter) BeanUtils.instantiate(converterClazz);
		return converter;
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy