TypedList implements List<Object> { public boolean addAll(Collection<? extends Object> c) { return inner.addAll(convertToTypedObjects(c)); } TypedList(final ListType type);  TypedList(final ListType type, final Collection<? extends Object> collection); @SuppressWarnings("unchecked")  TypedList(final ListType type, final Object array); ListType getType(); Type getElementType(); void add(int index, Object element); boolean add(Object o); boolean addAll(Collection<? extends Object> c); boolean addAll(int index, Collection<? extends Object> c); void clear(); boolean contains(Object o); boolean containsAll(Collection<?> c); Object get(int index); int indexOf(Object o); boolean isEmpty(); Iterator<Object> iterator(); int lastIndexOf(Object o); ListIterator<Object> listIterator(); ListIterator<Object> listIterator(int index); Object remove(int index); boolean remove(Object o); boolean removeAll(Collection<?> c); boolean retainAll(Collection<?> c); Object set(int index, Object element); int size(); List<Object> subList(int fromIndex, int toIndex); Object[] toArray(); T[] toArray(T[] a); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testAddAll() throws Exception { List<Object> list = new TypedList(stringListType); String[] strings = new String[] { "a", "b", "c" }; assertTrue(list.addAll(Arrays.asList(strings))); assertEquals(strings.length, list.size()); for (int i = 0; i < strings.length; i++) { assertEquals(strings[i], list.get(i)); } assertFalse(list.addAll(Arrays.asList(new String[] {}))); try { list.addAll(null); fail(); } catch (NullPointerException e) { } try { list.addAll(Arrays.asList(new Integer[] { 1, 2, 3 })); fail(); } catch (UnassignableValueException e) { } assertTrue(list.addAll(2, Arrays.asList(strings))); assertEquals(strings.length * 2, list.size()); assertEquals(strings[0], list.get(0)); assertEquals(strings[1], list.get(1)); assertEquals(strings[0], list.get(2)); assertEquals(strings[1], list.get(3)); assertEquals(strings[2], list.get(4)); assertEquals(strings[2], list.get(5)); assertFalse(list.addAll(2, Arrays.asList(new String[] {}))); try { list.addAll(0, null); fail(); } catch (NullPointerException e) { } try { list.addAll(-1, Arrays.asList(strings)); } catch (IndexOutOfBoundsException e) { } try { list.addAll(list.size() + 1, Arrays.asList(strings)); } catch (IndexOutOfBoundsException e) { } try { list.addAll(0, Arrays.asList(new Object[] { "string", 1 })); } catch (UnassignableValueException e) { } }