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

com.jd.httpservice.agent.StringConverterFactory 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.StringConverter;
import com.jd.httpservice.converters.ObjectToStringConverter;

abstract class StringConverterFactory {
	
	public static final StringConverter DEFAULT_PARAM_CONVERTER = new ObjectToStringConverter();
	
	public static StringConverter instantiateStringConverter(Class converterClazz) {
		StringConverter converter = null;
		if (converterClazz != null) {
			if (!StringConverter.class.isAssignableFrom(converterClazz)) {
				throw new IllegalHttpServiceDefinitionException(
						"The specified converter of path param doesn't implement the interface "
								+ StringConverter.class.getName() + "!");
			}

			converter = (StringConverter) BeanUtils.instantiate(converterClazz);
		} else {
			// create default converter;
			converter = DEFAULT_PARAM_CONVERTER;
		}
		return converter;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy