ListFormat { public static List<String> parse(String input) { List<String> ret = new ArrayList<>(); if (input.length() > 0) { input = input.substring(1, input.length() - 1); StringTokenizer st = new StringTokenizer(input, ","); while (st.hasMoreTokens()) { String s = st.nextToken().trim(); if (s.charAt(0) == '"') ret.add(s.substring(1, s.length() - 1)); else { ret.add(s); } } } return ret; }  static String format(Object[] data); static String format(List<?> data); static List<String> parse(String input);  }
@Test public void testParse() { List<String> ret = ListFormat.parse(FORMATTED); assertEquals(3, ret.size()); assertEquals(UNFORMATTED[0], ret.get(0)); assertEquals(UNFORMATTED[2], ret.get(2)); }
@Test public void testParseEmpty() { List<String> ret = ListFormat.parse("[]"); assertNotNull(ret); assertEquals(0, ret.size()); }