top.jfunc.common.http.withconverter.ConverterOkHttp3SmartHttpClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of network Show documentation
Show all versions of network Show documentation
http客户端请求工具类,有多种实现:OKHttp3、ApacheHttpClient、HttpURLConnection,可以随意切换http实现
package top.jfunc.common.http.withconverter;
import top.jfunc.common.converter.Converter;
import top.jfunc.common.http.smart.OkHttp3SmartHttpClient;
import java.util.Objects;
/**
* 返回结果String转换为
* @author xiongshiyan at 2018/1/11
*/
public class ConverterOkHttp3SmartHttpClient extends OkHttp3SmartHttpClient implements ConverterSmartHttpClient {
private Converter converter;
public ConverterOkHttp3SmartHttpClient(Converter converter){
this.converter = Objects.requireNonNull(converter);
}
public ConverterOkHttp3SmartHttpClient(){}
@Override
public ConverterSmartHttpClient setConverter(Converter converter) {
this.converter = Objects.requireNonNull(converter);
return this;
}
@Override
public R convert(String src, Class clazz) {
Converter.checkNull(this.converter);
return converter.convert(src , clazz);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy