package flagtest; interface Immutable{} interface Replacable extends Immutable{} interface Reducable extends Immutable{} interface Appendable extends Immutable{} interface Mutable extends Replacable, Reducable, Appendable{} interface _Iterator{} boolean hasNext(_Iterator); E next(_Iterator); void remove(_Iterator); interface _ListIterator extends _Iterator{} boolean hasPrevious(_ListIterator); E previous(_ListIterator); int nextIndex(_ListIterator); int previousIndex(_ListIterator); void set(_ListIterator, E); void add(_ListIterator, E); interface _Collection{} boolean isEmpty(_Collection); boolean contains(_Collection, E); boolean containsAll(_Collection, _Collection); _Iterator iterator(_Collection); int size(_Collection); boolean remove(_Collection ,E); boolean removeAll(_Collection, _Collection); boolean retainAll(_Collection, _Collection); void clear(_Collection); boolean add(_Collection, E); boolean addAll(_Collection, _Collection); Collection getInternal(_Collection); interface _List extends _Collection {} E get(_List, int); _ListIterator listIterator(_List, int i = 0); int indexOf(_List, E); int lastIndexOf(_List, E); E set(_List, int, E); E removeAt(_List, int); void add(_List, int, E); boolean addAll(_List, int, _Collection); _List subList(_List, int from, int to); interface _Set extends _Collection {} class _ArrayList implements _List { ArrayList arrayList; getInternal() = arrayList; isEmpty() = arrayList.isEmpty(); contains(elem) = arrayList.contains(elem); containsAll(coll) = arrayList.containsAll(coll.getInternal()); iterator() = new _IteratorWrapper(iterator: arrayList.iterator()); size() = arrayList.size(); remove(elem) = arrayList.remove(elem); removeAll(coll) = arrayList.removeAll(coll.getInternal()); retainAll(coll) = arrayList.retainAll(coll.getInternal()); clear() = arrayList.clear(); add(elem) = arrayList.add(elem); addAll(coll) = arrayList.addAll(coll.getInternal()); get(index) = arrayList.get(index); listIterator(index) = new _ListIteratorWrapper(listIterator: arrayList.listIterator(index)); indexOf(elem) = arrayList.indexOf(elem); lastIndexOf(elem) = arrayList.lastIndexOf(elem); set(index, elem) = arrayList.set(index, elem); removeAt(index) = arrayList.removeAt(index); add(index, elem) = arrayList.add(index, elem); addAll(index, coll) = arrayList.addAll(index, coll.getInternal()); subList(from, to) = new _ListWrapper(list: arrayList.subList(from, to)); } class _LinkedList implements _List { LinkedList linkedList; getInternal() = linkedList; isEmpty() = linkedList.isEmpty(); contains(elem) = linkedList.contains(elem); containsAll(coll) = linkedList.containsAll(coll.getInternal()); iterator() = new _IteratorWrapper(iterator: linkedList.iterator()); size() = linkedList.size(); remove(elem) = linkedList.remove(elem); removeAll(coll) = linkedList.removeAll(coll.getInternal()); retainAll(coll) = linkedList.retainAll(coll.getInternal()); clear() = linkedList.clear(); add(elem) = linkedList.add(elem); addAll(coll) = linkedList.addAll(coll.getInternal()); get(index) = linkedList.get(index); listIterator(index) = new _ListIteratorWrapper(listIterator: linkedList.listIterator(index)); indexOf(elem) = linkedList.indexOf(elem); lastIndexOf(elem) = linkedList.lastIndexOf(elem); set(index, elem) = linkedList.set(index, elem); removeAt(index) = linkedList.removeAt(index); add(index, elem) = linkedList.add(index, elem); addAll(index, coll) = linkedList.addAll(index, coll.getInternal()); subList(from, to) = new _ListWrapper(list: linkedList.subList(from, to)); } class _Array implements _List { Array array; getInternal() = array; isEmpty() = array.isEmpty(); contains(elem) = array.contains(elem); containsAll(coll) = array.containsAll(coll.getInternal()); iterator() = new _IteratorWrapper(iterator: array.iterator()); size() = array.size(); get(index) = array.get(index); listIterator(index) = new _ListIteratorWrapper(listIterator: array.listIterator(index)); indexOf(elem) = array.indexOf(elem); lastIndexOf(elem) = array.lastIndexOf(elem); set(index, elem){ array[index] = elem; return elem; } subList(from, to) = new _ListWrapper(list: array.subList(from, to)); } class _HashSet implements _Set { HashSet hashSet; getInternal() = hashSet; isEmpty() = hashSet.isEmpty(); contains(elem) = hashSet.contains(elem); containsAll(coll) = hashSet.containsAll(coll.getInternal()); iterator() = new _IteratorWrapper(iterator: hashSet.iterator()); size() = hashSet.size(); remove(elem) = hashSet.remove(elem); removeAll(coll) = hashSet.removeAll(coll.getInternal()); retainAll(coll) = hashSet.retainAll(coll.getInternal()); clear() = hashSet.clear(); add(elem) = hashSet.add(elem); addAll(coll) = hashSet.addAll(coll.getInternal()); } class _IteratorWrapper implements _Iterator{ Iterator iterator; hasNext() = iterator.hasNext(); next() = iterator.next(); remove() = iterator.remove(); } class _ListIteratorWrapper implements _ListIterator{ ListIterator listIterator; hasNext() = listIterator.hasNext(); next() = listIterator.next(); remove() = listIterator.remove(); hasPrevious() = listIterator.hasPrevious(); previous() = listIterator.previous(); nextIndex() = listIterator.nextIndex(); previousIndex() = listIterator.previousIndex(); set(elem) = listIterator.set(elem); add(elem) = listIterator.add(elem); } class _ListWrapper implements _List { List list; getInternal() = list; isEmpty() = list.isEmpty(); contains(elem) = list.contains(elem); containsAll(coll) = list.containsAll(coll.getInternal()); iterator() = new _IteratorWrapper(iterator: list.iterator()); size() = list.size(); remove(elem) = list.remove(elem); removeAll(coll) = list.removeAll(coll.getInternal()); retainAll(coll) = list.retainAll(coll.getInternal()); clear() = list.clear(); add(elem) = list.add(elem); addAll(coll) = list.addAll(coll.getInternal()); get(index) = list.get(index); listIterator(index) = new _ListIteratorWrapper(listIterator: list.listIterator(index)); indexOf(elem) = list.indexOf(elem); lastIndexOf(elem) = list.lastIndexOf(elem); set(index, elem) = list.set(index, elem); removeAt(index) = list.removeAt(index); add(index, elem) = list.add(index, elem); addAll(index, coll) = list.addAll(index, coll.getInternal()); subList(from, to) = new _ListWrapper(list: list.subList(from, to)); }