package com.fq.channel.sdk.base.exception;

import com.fq.threelib.gson.Gson;
import com.fq.threelib.gson.TypeAdapter;
import com.fq.threelib.gson.TypeAdapterFactory;
import com.fq.threelib.gson.reflect.TypeToken;

/**
 * Created by Ethan on 2017/7/6.
 * 生成Json处理null 转换成 “” 相关类
 */

public class NullStringToEmptyAdapterFactory<T> implements TypeAdapterFactory {
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
        Class<T> rawType = (Class<T>) type.getRawType();
        if (rawType != String.class) {
            return null;
        }
        return (TypeAdapter<T>) new StringNullAdapter();
    }
}