ImmutableAppendedList implements List<T> { @Override @SuppressWarnings( "synthetic-access" ) public Iterator<T> iterator() { final Iterator<T> parentIterator = parent.iterator(); return new Iterator<T>() { boolean finished = false; @Override public boolean hasNext() { return parentIterator.hasNext() || !finished; } @Override public T next() { if (parentIterator.hasNext()) return parentIterator.next(); if (finished) throw new NoSuchElementException(); finished = true; return element; } @Override public void remove() { throw new UnsupportedOperationException(); } }; } ImmutableAppendedList( List<T> parent,
                                  T element ); @Override boolean contains( Object o ); @Override boolean containsAll( Collection<?> c ); @Override T get( int index ); @Override int indexOf( Object o ); @Override boolean isEmpty(); @Override @SuppressWarnings( "synthetic-access" ) Iterator<T> iterator(); @Override int lastIndexOf( Object o ); @Override ListIterator<T> listIterator(); @Override @SuppressWarnings( "synthetic-access" ) ListIterator<T> listIterator( final int index ); @Override int size(); @Override List<T> subList( int fromIndex,
                            int toIndex ); @Override Object[] toArray(); @Override @SuppressWarnings( "unchecked" ) X[] toArray( X[] a ); @Override int hashCode(); @Override boolean equals( Object obj ); @Override String toString(); @Override void add( int index,
                     T element ); @Override boolean add( T o ); @Override boolean addAll( Collection<? extends T> c ); @Override boolean addAll( int index,
                           Collection<? extends T> c ); @Override void clear(); @Override boolean remove( Object o ); @Override T remove( int index ); @Override boolean removeAll( Collection<?> c ); @Override boolean retainAll( Collection<?> c ); @Override T set( int index,
                  T element );  }
@Test public void shouldIterateOverAllValues() { Iterator<String> iter = list.iterator(); int i = 0; while (iter.hasNext()) { assertThat(iter.next(), is(data[i++])); } }