miduo_server/jieling-dbgen/gen/dblog/WrapList.java

296 lines
6.6 KiB
Java

package dblog;
/**
* Description: des
* Author: zsx
* CreateDate: 2020/4/16 20:54
*/
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
class WrapList<E> implements List<E> {
private LogList<E> root;
private List<E> wrapped;
public WrapList(LogList<E> root, List<E> wrapped) {
this.root = root;
this.wrapped = wrapped;
}
protected void beforeChange() {
this.root.beforeChange();
}
protected void afterAdd(E add) {
this.root.afterAdd(add);
}
protected void beforeRemove(E remove) {
this.root.beforeRemove(remove);
}
protected List<E> getWrapped() {
return this.wrapped;
}
public boolean add(E e) {
this.beforeChange();
if (this.wrapped.add(e)) {
this.afterAdd(e);
return true;
} else {
return false;
}
}
public void add(int index, E element) {
this.beforeChange();
this.wrapped.add(index, element);
this.afterAdd(element);
}
public boolean addAll(Collection<? extends E> c) {
this.beforeChange();
if (!this.wrapped.addAll(c)) {
return false;
} else {
Iterator var2 = c.iterator();
while(var2.hasNext()) {
E e = (E)var2.next();
this.afterAdd(e);
}
return true;
}
}
public boolean addAll(int index, Collection<? extends E> c) {
this.beforeChange();
if (!this.wrapped.addAll(index, c)) {
return false;
} else {
Iterator var3 = c.iterator();
while(var3.hasNext()) {
E e = (E)var3.next();
this.afterAdd(e);
}
return true;
}
}
public void clear() {
this.beforeChange();
Iterator var1 = this.wrapped.iterator();
while(var1.hasNext()) {
E e = (E)var1.next();
this.beforeRemove(e);
}
this.wrapped.clear();
}
public boolean contains(Object o) {
return this.wrapped.contains(o);
}
public boolean containsAll(Collection<?> c) {
return this.wrapped.containsAll(c);
}
public boolean equals(Object obj) {
return this.wrapped.equals(obj);
}
public E get(int index) {
E v = this.wrapped.get(index);
return v;
}
public int hashCode() {
return this.wrapped.hashCode();
}
public int indexOf(Object o) {
return this.wrapped.indexOf(o);
}
public boolean isEmpty() {
return this.wrapped.isEmpty();
}
public Iterator<E> iterator() {
return new WrapList.WrapIt();
}
public int lastIndexOf(Object o) {
return this.wrapped.lastIndexOf(o);
}
public ListIterator<E> listIterator() {
return new WrapList.WrapListIt();
}
public ListIterator<E> listIterator(int index) {
return new WrapList.WrapListIt(index);
}
public E remove(int index) {
this.beforeChange();
E removed = this.wrapped.remove(index);
this.beforeRemove(removed);
return removed;
}
public boolean remove(Object o) {
int index = this.indexOf(o);
if (index < 0) {
return false;
} else {
this.remove(index);
return true;
}
}
public boolean removeAll(Collection<?> c) {
boolean modified = false;
Iterator e = this.iterator();
while(e.hasNext()) {
if (c.contains(e.next())) {
e.remove();
modified = true;
}
}
return modified;
}
public boolean retainAll(Collection<?> c) {
boolean modified = false;
Iterator e = this.iterator();
while(e.hasNext()) {
if (!c.contains(e.next())) {
e.remove();
modified = true;
}
}
return modified;
}
public E set(int index, E element) {
this.beforeChange();
E removed = this.wrapped.set(index, element);
this.beforeRemove(removed);
this.afterAdd(element);
return removed;
}
public int size() {
return this.wrapped.size();
}
public List<E> subList(int fromIndex, int toIndex) {
return new WrapList(this.root, this.wrapped.subList(fromIndex, toIndex));
}
public Object[] toArray() {
return this.wrapped.toArray();
}
public <X> X[] toArray(X[] a) {
return this.wrapped.toArray(a);
}
public String toString() {
return this.wrapped.toString();
}
private class WrapListIt implements ListIterator<E> {
private ListIterator<E> it;
private E current;
WrapListIt() {
this.it = WrapList.this.wrapped.listIterator();
}
WrapListIt(int index) {
this.it = WrapList.this.wrapped.listIterator(index);
}
public void add(E e) {
WrapList.this.beforeChange();
this.it.add(e);
WrapList.this.afterAdd(e);
}
public boolean hasNext() {
return this.it.hasNext();
}
public boolean hasPrevious() {
return this.it.hasPrevious();
}
public E next() {
return this.current = this.it.next();
}
public int nextIndex() {
return this.it.nextIndex();
}
public E previous() {
return this.current = this.it.previous();
}
public int previousIndex() {
return this.it.previousIndex();
}
public void remove() {
WrapList.this.beforeChange();
WrapList.this.beforeRemove(this.current);
this.it.remove();
}
public void set(E e) {
WrapList.this.beforeChange();
WrapList.this.beforeRemove(this.current);
this.it.set(e);
WrapList.this.afterAdd(e);
}
}
private class WrapIt implements Iterator<E> {
private Iterator<E> it;
private E current;
private WrapIt() {
this.it = WrapList.this.wrapped.iterator();
}
public boolean hasNext() {
return this.it.hasNext();
}
public E next() {
return this.current = this.it.next();
}
public void remove() {
WrapList.this.beforeChange();
WrapList.this.beforeRemove(this.current);
this.it.remove();
}
}
}