@Test(groups = {"gobblin.util.io"}) public void test() { Gson gson = GsonInterfaceAdapter.getGson(Object.class); TestClass test = new TestClass(); test.absent = Optional.absent(); Assert.assertNotEquals(test, new TestClass()); String ser = gson.toJson(test); BaseClass deser = gson.fromJson(ser, BaseClass.class); Assert.assertEquals(test, deser); }
public static <T> Gson getGson(Class<T> clazz) { Gson gson = new GsonBuilder().registerTypeAdapterFactory(new GsonInterfaceAdapter(clazz)).create(); return gson; }
GsonInterfaceAdapter implements TypeAdapterFactory { public static <T> Gson getGson(Class<T> clazz) { Gson gson = new GsonBuilder().registerTypeAdapterFactory(new GsonInterfaceAdapter(clazz)).create(); return gson; } }
GsonInterfaceAdapter implements TypeAdapterFactory { public static <T> Gson getGson(Class<T> clazz) { Gson gson = new GsonBuilder().registerTypeAdapterFactory(new GsonInterfaceAdapter(clazz)).create(); return gson; }  }
GsonInterfaceAdapter implements TypeAdapterFactory { public static <T> Gson getGson(Class<T> clazz) { Gson gson = new GsonBuilder().registerTypeAdapterFactory(new GsonInterfaceAdapter(clazz)).create(); return gson; }  @Override TypeAdapter<R> create(Gson gson, TypeToken<R> type); static Gson getGson(Class<T> clazz); }
GsonInterfaceAdapter implements TypeAdapterFactory { public static <T> Gson getGson(Class<T> clazz) { Gson gson = new GsonBuilder().registerTypeAdapterFactory(new GsonInterfaceAdapter(clazz)).create(); return gson; }  @Override TypeAdapter<R> create(Gson gson, TypeToken<R> type); static Gson getGson(Class<T> clazz);  }