-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChangeNotifyingArrayList.java
More file actions
82 lines (67 loc) · 1.77 KB
/
Copy pathChangeNotifyingArrayList.java
File metadata and controls
82 lines (67 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package org.jsoup.helper;
import java.util.ArrayList;
import java.util.Collection;
/**
* Implementation of ArrayList that watches out for changes to the contents.
*/
public abstract class ChangeNotifyingArrayList<E> extends ArrayList<E> {
public ChangeNotifyingArrayList(int initialCapacity) {
super(initialCapacity);
}
public abstract void onContentsChanged();
@Override
public E set(int index, E element) {
onContentsChanged();
return super.set(index, element);
}
@Override
public boolean add(E e) {
onContentsChanged();
return super.add(e);
}
@Override
public void add(int index, E element) {
onContentsChanged();
super.add(index, element);
}
@Override
public E remove(int index) {
onContentsChanged();
return super.remove(index);
}
@Override
public boolean remove(Object o) {
onContentsChanged();
return super.remove(o);
}
@Override
public void clear() {
onContentsChanged();
super.clear();
}
@Override
public boolean addAll(Collection<? extends E> c) {
onContentsChanged();
return super.addAll(c);
}
@Override
public boolean addAll(int index, Collection<? extends E> c) {
onContentsChanged();
return super.addAll(index, c);
}
@Override
protected void removeRange(int fromIndex, int toIndex) {
onContentsChanged();
super.removeRange(fromIndex, toIndex);
}
@Override
public boolean removeAll(Collection<?> c) {
onContentsChanged();
return super.removeAll(c);
}
@Override
public boolean retainAll(Collection<?> c) {
onContentsChanged();
return super.retainAll(c);
}
}