package com.lukouguoji.module_base.http.user;


import androidx.annotation.Nullable;

import java.lang.reflect.Type;

import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Retrofit;
import java.lang.annotation.Annotation;

public class StringConverterFactory extends Converter.Factory {
    public static Converter.Factory create() {
        return new StringConverterFactory();
    }

    public @Nullable
    Converter<ResponseBody, String> responseBodyConverter(
            Type type, Annotation[] annotations, Retrofit retrofit) {

        if(type != String.class){
            return null;
        }

        return new StringResponseBodyConverter();
    }

    public @Nullable Converter<String, RequestBody> requestBodyConverter(
            Type type,
            Annotation[] parameterAnnotations,
            Annotation[] methodAnnotations,
            Retrofit retrofit) {

        if(type != String.class){
            return null;
        }

        return new StringRequestBodyConverter();
    }

    public @Nullable Converter<String, String> stringConverter(
            Type type, Annotation[] annotations, Retrofit retrofit) {
        return null;
    }
}
