/* * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code 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 General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.util.*; /** * A complete List implementation that inherits the reversed() method * from List. Useful for testing ReverseOrderListView. * Underlying implementation provided by ArrayList. */ public class SimpleList implements List { final List list; public SimpleList() { list = new ArrayList<>(); } public SimpleList(Collection c) { list = new ArrayList<>(c); } // ========== Object ========== public boolean equals(Object o) { return list.equals(o); } public int hashCode() { return list.hashCode(); } public String toString() { return list.toString(); } // ========== Collection ========== public boolean add(E e) { return list.add(e); } public boolean addAll(Collection c) { return list.addAll(c); } public void clear() { list.clear(); } public boolean contains(Object o) { return list.contains(o); } public boolean containsAll(Collection c) { return list.containsAll(c); } public boolean isEmpty() { return list.isEmpty(); } public Iterator iterator() { return list.iterator(); } public boolean remove(Object o) { return list.remove(o); } public boolean removeAll(Collection c) { return list.removeAll(c); } public boolean retainAll(Collection c) { return list.retainAll(c); } public int size() { return list.size(); } public Object[] toArray() { return list.toArray(); } public T[] toArray(T[] a) { return list.toArray(a); } // ========== List ========== public void add(int index, E element) { list.add(index, element); } public boolean addAll(int index, Collection c) { return list.addAll(index, c); } public E get(int index) { return list.get(index); } public int indexOf(Object o) { return list.indexOf(o); } public int lastIndexOf(Object o) { return list.lastIndexOf(o); } public ListIterator listIterator() { return list.listIterator(); } public ListIterator listIterator(int index) { return list.listIterator(index); } public E remove(int index) { return list.remove(index); } public E set(int index, E element) { return list.set(index, element); } public List subList(int fromIndex, int toIndex) { return list.subList(fromIndex, toIndex); } }