@Test public void testEmptyAndNullSave() throws JsonParserException { final List<Tab> emptyList = Collections.emptyList(); String returnedJson = TabsJsonHelper.getJsonToSave(emptyList); assertTrue(isTabsArrayEmpty(returnedJson)); final List<Tab> nullList = null; returnedJson = TabsJsonHelper.getJsonToSave(nullList); assertTrue(isTabsArrayEmpty(returnedJson)); }
public static String getJsonToSave(@Nullable final List<Tab> tabList) { final JsonStringWriter jsonWriter = JsonWriter.string(); jsonWriter.object(); jsonWriter.array(JSON_TABS_ARRAY_KEY); if (tabList != null) { for (final Tab tab : tabList) { tab.writeJsonOn(jsonWriter); } } jsonWriter.end(); jsonWriter.end(); return jsonWriter.done(); }
TabsJsonHelper { public static String getJsonToSave(@Nullable final List<Tab> tabList) { final JsonStringWriter jsonWriter = JsonWriter.string(); jsonWriter.object(); jsonWriter.array(JSON_TABS_ARRAY_KEY); if (tabList != null) { for (final Tab tab : tabList) { tab.writeJsonOn(jsonWriter); } } jsonWriter.end(); jsonWriter.end(); return jsonWriter.done(); } }
TabsJsonHelper { public static String getJsonToSave(@Nullable final List<Tab> tabList) { final JsonStringWriter jsonWriter = JsonWriter.string(); jsonWriter.object(); jsonWriter.array(JSON_TABS_ARRAY_KEY); if (tabList != null) { for (final Tab tab : tabList) { tab.writeJsonOn(jsonWriter); } } jsonWriter.end(); jsonWriter.end(); return jsonWriter.done(); } private  TabsJsonHelper(); }
TabsJsonHelper { public static String getJsonToSave(@Nullable final List<Tab> tabList) { final JsonStringWriter jsonWriter = JsonWriter.string(); jsonWriter.object(); jsonWriter.array(JSON_TABS_ARRAY_KEY); if (tabList != null) { for (final Tab tab : tabList) { tab.writeJsonOn(jsonWriter); } } jsonWriter.end(); jsonWriter.end(); return jsonWriter.done(); } private  TabsJsonHelper(); static List<Tab> getTabsFromJson(@Nullable final String tabsJson); static String getJsonToSave(@Nullable final List<Tab> tabList); static List<Tab> getDefaultTabs(); }
TabsJsonHelper { public static String getJsonToSave(@Nullable final List<Tab> tabList) { final JsonStringWriter jsonWriter = JsonWriter.string(); jsonWriter.object(); jsonWriter.array(JSON_TABS_ARRAY_KEY); if (tabList != null) { for (final Tab tab : tabList) { tab.writeJsonOn(jsonWriter); } } jsonWriter.end(); jsonWriter.end(); return jsonWriter.done(); } private  TabsJsonHelper(); static List<Tab> getTabsFromJson(@Nullable final String tabsJson); static String getJsonToSave(@Nullable final List<Tab> tabList); static List<Tab> getDefaultTabs();  }