@Test public void deserializes() { Category[] input = new CategorySerializer().deserialize(expectedOutput); Assert.assertArrayEquals(expectedInput, input); }
@Override @Nullable public Category[] deserialize(String string) { if (string != null) { String[] ids = string.split(";"); List<Category> categories = new ArrayList<>(); for (String id : ids) { try { int stableId = Integer.parseInt(id); Category category = Category.fromStableId(stableId); if (category != null) { categories.add(category); } } catch (NumberFormatException exception) { Log.e(TAG, exception.getMessage()); } } return categories.toArray(new Category[categories.size()]); } else { return null; } }
CategorySerializer implements Serializer<Category[], String> { @Override @Nullable public Category[] deserialize(String string) { if (string != null) { String[] ids = string.split(";"); List<Category> categories = new ArrayList<>(); for (String id : ids) { try { int stableId = Integer.parseInt(id); Category category = Category.fromStableId(stableId); if (category != null) { categories.add(category); } } catch (NumberFormatException exception) { Log.e(TAG, exception.getMessage()); } } return categories.toArray(new Category[categories.size()]); } else { return null; } } }
CategorySerializer implements Serializer<Category[], String> { @Override @Nullable public Category[] deserialize(String string) { if (string != null) { String[] ids = string.split(";"); List<Category> categories = new ArrayList<>(); for (String id : ids) { try { int stableId = Integer.parseInt(id); Category category = Category.fromStableId(stableId); if (category != null) { categories.add(category); } } catch (NumberFormatException exception) { Log.e(TAG, exception.getMessage()); } } return categories.toArray(new Category[categories.size()]); } else { return null; } }  }
CategorySerializer implements Serializer<Category[], String> { @Override @Nullable public Category[] deserialize(String string) { if (string != null) { String[] ids = string.split(";"); List<Category> categories = new ArrayList<>(); for (String id : ids) { try { int stableId = Integer.parseInt(id); Category category = Category.fromStableId(stableId); if (category != null) { categories.add(category); } } catch (NumberFormatException exception) { Log.e(TAG, exception.getMessage()); } } return categories.toArray(new Category[categories.size()]); } else { return null; } }  @Override @Nullable String serialize(Category[] categories); @Override @Nullable Category[] deserialize(String string); }
CategorySerializer implements Serializer<Category[], String> { @Override @Nullable public Category[] deserialize(String string) { if (string != null) { String[] ids = string.split(";"); List<Category> categories = new ArrayList<>(); for (String id : ids) { try { int stableId = Integer.parseInt(id); Category category = Category.fromStableId(stableId); if (category != null) { categories.add(category); } } catch (NumberFormatException exception) { Log.e(TAG, exception.getMessage()); } } return categories.toArray(new Category[categories.size()]); } else { return null; } }  @Override @Nullable String serialize(Category[] categories); @Override @Nullable Category[] deserialize(String string);  }