com.cmonbaby.http.converter.FastJsonConverterFactory Maven / Gradle / Ivy
Show all versions of http_lower Show documentation
package com.cmonbaby.http.converter;
import androidx.annotation.NonNull;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Retrofit;
/**
* Author: Simon
*
QO: 8950764
*
Email: [email protected]
*
WebSize: https://www.cmonbaby.com
*
Version: 1.0.0
*
Date: 2020/12/28
*
Description: FastJson转换类
*/
public final class FastJsonConverterFactory extends Converter.Factory {
public static FastJsonConverterFactory create() {
return new FastJsonConverterFactory();
}
/**
* 需要重写父类中responseBodyConverter,该方法用来转换服务器返回数据
*/
@Override
public Converter responseBodyConverter(@NonNull Type type,
@NonNull Annotation[] annotations,
@NonNull Retrofit retrofit) {
return new FastJsonResponseBodyConverter<>(type);
}
/**
* 需要重写父类中responseBodyConverter,该方法用来转换发送给服务器的数据
*/
@Override
public Converter, RequestBody> requestBodyConverter(@NonNull Type type,
@NonNull Annotation[] parameterAnnotations,
@NonNull Annotation[] methodAnnotations,
@NonNull Retrofit retrofit) {
return new FastJsonRequestBodyConverter<>();
}
}