ItemUtils { public static List<Integer> toItemList(final String itemsString) { if (Strings.isNullOrEmpty(itemsString)) { return Collections.emptyList(); } String[] items = itemsString.split(DELIMITER); List<Integer> result = new ArrayList<>(items.length); for (String each : items) { int item = Integer.parseInt(each); if (!result.contains(item)) { result.add(item); } } return result; }  static List<Integer> toItemList(final String itemsString); static String toItemsString(final List<Integer> items);  }
@Test public void assertTtoItemListWhenNull() { assertThat(ItemUtils.toItemList(null), is(Collections.EMPTY_LIST)); }
@Test public void assertToItemListWhenEmpty() { assertThat(ItemUtils.toItemList(""), is(Collections.EMPTY_LIST)); }
@Test public void assertToItemList() { assertThat(ItemUtils.toItemList("0,1,2"), is(Arrays.asList(0, 1, 2))); }
@Test public void assertToItemListForDuplicated() { assertThat(ItemUtils.toItemList("0,1,2,2"), is(Arrays.asList(0, 1, 2))); }