package com.sheep.gamegroup.model.api;

import com.sheep.gamegroup.model.entity.BaseMessage;

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Retrofit;

/**
 * Created by ljy on 2018/3/8.
 */
public class StringConverterFactory extends Converter.Factory {

    public static StringConverterFactory create(){
        return new StringConverterFactory();
    }

    @Override
    public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
        if (type == String.class) {
            return new StringConverter();
        } else if(type == BaseMessage.class) {
            //其它类型我们不处理，返回null就行
            return new BaseMessageConverter();
        }
        return null;
    }
}
