ImmutableAppendedList implements List<T> { @Override public boolean equals( Object obj ) { if (obj == this) return true; if (obj instanceof List<?>) { List<?> that = (List<?>)obj; if (this.size() != that.size()) return false; Iterator<?> thisIter = this.iterator(); Iterator<?> thatIter = that.iterator(); while (thisIter.hasNext()) { Object thisValue = thisIter.next(); Object thatValue = thatIter.next(); if (thisValue == null) { if (thatValue != null) return false; } else { if (!thisValue.equals(thatValue)) return false; } } return true; } return super.equals(obj); } 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 shouldBeEqualToEquivalentArrayList() { List<String> copy = new ArrayList<String>(list); assertThat(list.equals(copy), is(true)); }