1 package org.djutils.event.collection;
2
3 import java.io.Serializable;
4 import java.util.ListIterator;
5
6 import org.djutils.event.EventType;
7 import org.djutils.metadata.MetaData;
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 public class EventProducingListIterator<T> extends EventProducingIterator<T> implements ListIterator<T>, Serializable
26 {
27
28 private static final long serialVersionUID = 20191230L;
29
30
31 public static final EventType OBJECT_ADDED_EVENT = new EventType("OBJECT_ADDED_EVENT", MetaData.EMPTY);
32
33
34 public static final EventType OBJECT_CHANGED_EVENT = new EventType("OBJECT_CHANGED_EVENT", MetaData.EMPTY);
35
36
37
38
39
40 public EventProducingListIterator(final ListIterator<T> wrappedIterator)
41 {
42 super(wrappedIterator);
43 }
44
45 @Override
46 protected ListIterator<T> getWrappedIterator()
47 {
48 return (ListIterator<T>) super.getWrappedIterator();
49 }
50
51 @Override
52 public boolean hasPrevious()
53 {
54 return getWrappedIterator().hasPrevious();
55 }
56
57 @Override
58 public T previous()
59 {
60 return getWrappedIterator().previous();
61 }
62
63 @Override
64 public int nextIndex()
65 {
66 return getWrappedIterator().nextIndex();
67 }
68
69 @Override
70 public int previousIndex()
71 {
72 return getWrappedIterator().previousIndex();
73 }
74
75 @Override
76 public void set(final T e)
77 {
78 getWrappedIterator().set(e);
79 fireEvent(OBJECT_CHANGED_EVENT);
80 }
81
82 @Override
83 public void add(final T e)
84 {
85 getWrappedIterator().add(e);
86 fireEvent(OBJECT_ADDED_EVENT);
87 }
88
89 }