|
@@ -6,20 +6,20 @@ public final class ListenerList<T> {
|
6
|
6
|
public static final int PRIORITY_HIGH = 100;
|
7
|
7
|
public static final int PRIORITY_DEFAULT = 0;
|
8
|
8
|
public static final int PRIORITY_LOW = -100;
|
9
|
|
- private ListenerList<T>.EventListenerNode first = null;
|
10
|
|
- private ListenerList<T>.EventListenerNode last = null;
|
|
9
|
+ private EventListenerNode first = null;
|
|
10
|
+ private EventListenerNode last = null;
|
11
|
11
|
|
12
|
12
|
public ListenerHandle<T> add(T listener) {
|
13
|
13
|
return this.add(listener, ListenerList.PRIORITY_DEFAULT);
|
14
|
14
|
}
|
15
|
15
|
|
16
|
16
|
public ListenerHandle<T> add(T listener, int priority) {
|
17
|
|
- ListenerList<T>.EventListenerNode node = new ListenerList<T>.EventListenerNode(listener, priority);
|
|
17
|
+ EventListenerNode node = new EventListenerNode(listener, priority);
|
18
|
18
|
if (first == null) {
|
19
|
19
|
this.first = this.last = node;
|
20
|
20
|
}
|
21
|
21
|
else {
|
22
|
|
- ListenerList<T>.EventListenerNode previousNode = last;
|
|
22
|
+ EventListenerNode previousNode = last;
|
23
|
23
|
while (previousNode != null && priority > previousNode.priority)
|
24
|
24
|
previousNode = previousNode.prev;
|
25
|
25
|
if (previousNode == null) {
|
|
@@ -44,7 +44,7 @@ public final class ListenerList<T> {
|
44
|
44
|
}
|
45
|
45
|
|
46
|
46
|
public void accept(Consumer<T> consumer) {
|
47
|
|
- ListenerList<T>.EventListenerNode current = first;
|
|
47
|
+ EventListenerNode current = first;
|
48
|
48
|
while (current != null) {
|
49
|
49
|
consumer.accept(current.listener);
|
50
|
50
|
current = current.next;
|
|
@@ -57,8 +57,8 @@ public final class ListenerList<T> {
|
57
|
57
|
private final class EventListenerNode implements ListenerHandle<T>, AutoCloseable {
|
58
|
58
|
public final T listener;
|
59
|
59
|
private final int priority;
|
60
|
|
- private ListenerList<T>.EventListenerNode next = null;
|
61
|
|
- private ListenerList<T>.EventListenerNode prev = null;
|
|
60
|
+ private EventListenerNode next = null;
|
|
61
|
+ private EventListenerNode prev = null;
|
62
|
62
|
|
63
|
63
|
public EventListenerNode(T listener, int priority) {
|
64
|
64
|
this.listener = listener;
|