/*
 * Java Genetic Algorithm Library (@__identifier__@).
 * Copyright (c) @__year__@ Franz Wilhelmstötter
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * Author:
 *    Franz Wilhelmstötter (franz.wilhelmstoetter@gmx.at)
 *
 */
package org.jenetics.internal.util;

import java.util.AbstractList;
import java.util.RandomAccess;

/**
 * @author <a href="mailto:franz.wilhelmstoetter@gmx.at">Franz Wilhelmstötter</a>
 * @since 1.4
 * @version 1.4 &mdash; <em>$Date: 2013-07-08 $</em>
 */
public class ArrayProxyList<T> extends AbstractList<T>
	implements RandomAccess
{

	private final ArrayProxy<T> _proxy;

	ArrayProxyList(final ArrayProxy<T> proxy) {
		_proxy = proxy;
	}

	@Override
	public T get(final int index) {
		return _proxy.get(index);
	}

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

	@Override
	public int indexOf(final Object element) {
		int index = -1;
		if (element == null) {
			for (int i = _proxy._start, n = _proxy._end;
				i < n && index == -1; ++i)
			{
				if (_proxy.uncheckedOffsetGet(i) == null) {
					index = i;
				}
			}
		} else {
			for (int i = _proxy._start, n = _proxy._end;
				i < n && index == -1; ++i)
			{
				if (element.equals(_proxy.uncheckedOffsetGet(i))) {
					index = i;
				}
			}
		}

		return index;
	}

	@Override
	public boolean contains(final Object element) {
		return indexOf(element) != -1;
	}

	@Override
	public Object[] toArray() {
		final Object[] array = new Object[size()];
		for (int i = size(); --i >= 0;) {
			array[i] = _proxy.uncheckedGet(i);
		}
		return array;
	}

	@SuppressWarnings("unchecked")
	@Override
	public <E> E[] toArray(final E[] array) {
		if (array.length < size()) {
			final E[] copy = (E[])java.lang.reflect.Array.newInstance(
				array.getClass().getComponentType(), size()
			);
			for (int i = size(); --i >= 0;) {
				copy[i] = (E)_proxy.uncheckedGet(i);
			}

			return copy;
		}

		for (int i = size(); --i >= 0;) {
			array[i] = (E)_proxy.uncheckedGet(i);
		}
		return array;
	}

}

@@ -954,16 +954,65 @@
 .util;%0A%0A
+import static java.util.Objects.requireNonNull;%0A%0A
 import j
@@ -1034,16 +1034,16 @@
 ctList;%0A
-
 import j
@@ -1213,10 +1213,10 @@
 -07-
+1
 0
-8
  $%3C/
@@ -1345,16 +1345,23 @@
 roxy;%0A%0A%09
+public 
 ArrayPro
@@ -1407,21 +1407,68 @@
 proxy = 
-proxy
+requireNonNull(proxy, %22ArrayProxy must not be null%22)
 ;%0A%09%7D%0A%0A%09@

Add non-null precondition check.