@Test public void testEncodeAndDecode() { StringListResultFactory factory = new StringListResultFactory(); List<String> expected; List<String> value; expected = Lists.newArrayList(); value = factory.newFromValue(new Object[] {}); assertEquals(expected, value); value = factory.newFromValue(new String[] {}); assertEquals(expected, value); expected = Lists.newArrayList(new String[] { "foo" }); value = factory.newFromValue(new Object[] { "foo" }); assertEquals(expected, value); value = factory.newFromValue(new String[] { "foo" }); assertEquals(expected, value); expected = Lists.newArrayList(new String[] { "foo", "bar" }); value = factory.newFromValue(new Object[] { "foo", "bar" }); assertEquals(expected, value); value = factory.newFromValue(new String[] { "foo", "bar" }); assertEquals(expected, value); try { factory.newFromValue("bad"); fail("should not have converted"); } catch (ClassCastException e) { } try { factory.newFromValue(new Object[] { 1 }); fail("should not have converted"); } catch (ClassCastException e) { } try { factory.newFromValue(new Object[] { "1", 1 }); fail("should not have converted"); } catch (ClassCastException e) { } }
@Override public List<String> newFromValue(Object value) { List<String> strings = Lists.newArrayList(); List<Object> objects = Arrays.asList((Object[]) value); for (Object topic : objects) { strings.add((String) topic); } return strings; }
StringListResultFactory implements ResultFactory<List<String>> { @Override public List<String> newFromValue(Object value) { List<String> strings = Lists.newArrayList(); List<Object> objects = Arrays.asList((Object[]) value); for (Object topic : objects) { strings.add((String) topic); } return strings; } }
StringListResultFactory implements ResultFactory<List<String>> { @Override public List<String> newFromValue(Object value) { List<String> strings = Lists.newArrayList(); List<Object> objects = Arrays.asList((Object[]) value); for (Object topic : objects) { strings.add((String) topic); } return strings; }  }
StringListResultFactory implements ResultFactory<List<String>> { @Override public List<String> newFromValue(Object value) { List<String> strings = Lists.newArrayList(); List<Object> objects = Arrays.asList((Object[]) value); for (Object topic : objects) { strings.add((String) topic); } return strings; }  @Override List<String> newFromValue(Object value); }
StringListResultFactory implements ResultFactory<List<String>> { @Override public List<String> newFromValue(Object value) { List<String> strings = Lists.newArrayList(); List<Object> objects = Arrays.asList((Object[]) value); for (Object topic : objects) { strings.add((String) topic); } return strings; }  @Override List<String> newFromValue(Object value);  }