package com.antew.redditinpictures.library.json;

import com.antew.redditinpictures.library.enums.Vote;
import com.antew.redditinpictures.library.gson.VoteAdapter;
import com.antew.redditinpictures.library.logging.Log;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;

public class JsonDeserializer {
    public static final String TAG = JsonDeserializer.class.getSimpleName();
    private static Gson gson;

    public static <T> T deserialize(String json, Class<T> clazz) {
        try {
            return getGson().fromJson(json, clazz);
        } catch (JsonSyntaxException e) {
            Log.e(TAG, "deserialize - Error parsing JSON!", e);
        } catch (IllegalStateException e) {
            Log.e(TAG, "deserialize - Error parsing JSON!", e);
        }

        return null;
    }

    public static Gson getGson() {
        if (gson == null) {
            GsonBuilder builder = new GsonBuilder();
            builder.registerTypeAdapter(Vote.class, new VoteAdapter());
            builder.serializeNulls();
            gson = builder.create();
        }

        return gson;
    }
}

@@ -320,16 +320,39 @@
 ception;
+%0Aimport java.io.Reader;
 %0A%0Apublic
@@ -485,16 +485,402 @@
  gson;%0A%0A
+    public static %3CT%3E T deserialize(Reader json, Class%3CT%3E clazz) %7B%0A        try %7B%0A            return getGson().fromJson(json, clazz);%0A        %7D catch (JsonSyntaxException e) %7B%0A            Log.e(TAG, %22deserialize - Error parsing JSON!%22, e);%0A        %7D catch (IllegalStateException e) %7B%0A            Log.e(TAG, %22deserialize - Error parsing JSON!%22, e);%0A        %7D%0A%0A        return null;%0A    %7D%0A%0A
     publ

Add JSON deserializer which takes a reader