class NonNullElementWrapperList<E> extends AbstractList<E> implements RandomAccess {
  // Explicitly specify ArrayList as type to guarantee that delegate implements RandomAccess
  private final ArrayList<E> delegate;

  @SuppressWarnings("NonApiType")
  public NonNullElementWrapperList(ArrayList<E> delegate) {
    this.delegate = Objects.requireNonNull(delegate);
  }

  @Override
  public E get(int index) {
    return delegate.get(index);
  }

  @Override
  public int size() {
    return delegate.size();
  }

  private E nonNull(E element) {<FILL_FUNCTION_BODY>}

  @Override
  public E set(int index, E element) {
    return delegate.set(index, nonNull(element));
  }

  @Override
  public void add(int index, E element) {
    delegate.add(index, nonNull(element));
  }

  @Override
  public E remove(int index) {
    return delegate.remove(index);
  }

  /* The following methods are overridden because their default implementation is inefficient */

  @Override
  public void clear() {
    delegate.clear();
  }

  @SuppressWarnings("UngroupedOverloads") // this is intentionally ungrouped, see comment above
  @Override
  public boolean remove(Object o) {
    return delegate.remove(o);
  }

  @Override
  public boolean removeAll(Collection<?> c) {
    return delegate.removeAll(c);
  }

  @Override
  public boolean retainAll(Collection<?> c) {
    return delegate.retainAll(c);
  }

  @Override
  public boolean contains(Object o) {
    return delegate.contains(o);
  }

  @Override
  public int indexOf(Object o) {
    return delegate.indexOf(o);
  }

  @Override
  public int lastIndexOf(Object o) {
    return delegate.lastIndexOf(o);
  }

  @Override
  public Object[] toArray() {
    return delegate.toArray();
  }

  @Override
  public <T> T[] toArray(T[] a) {
    return delegate.toArray(a);
  }

  @Override
  public boolean equals(Object o) {
    return delegate.equals(o);
  }

  @Override
  public int hashCode() {
    return delegate.hashCode();
  }

  // TODO: Once Gson targets Java 8 also override List.sort
}

    if (element == null) {
      throw new NullPointerException("Element must be non-null");
    }
    return element;
  
<methods>public boolean add(E) ,public void add(int, E) ,public boolean addAll(int, Collection<? extends E>) ,public void clear() ,public boolean equals(java.lang.Object) ,public abstract E get(int) ,public int hashCode() ,public int indexOf(java.lang.Object) ,public Iterator<E> iterator() ,public int lastIndexOf(java.lang.Object) ,public ListIterator<E> listIterator() ,public ListIterator<E> listIterator(int) ,public E remove(int) ,public E set(int, E) ,public List<E> subList(int, int) <variables>protected transient int modCount