public DelegatingNotifyingListImpl(Collection<? extends E> collection) { super(collection); } /** * Returns <code>null</code>. * @return <code>null</code>. */ public Object getNotifier() { return null; } /** * Returns <code>null</code>. * @return <code>null</code>. */ public Object getFeature() { return null; } /** * Returns {@link Notification#NO_FEATURE_ID}. * @return <code>Notification.NO_FEATURE_ID</code>. */ public int getFeatureID() { return Notification.NO_FEATURE_ID; } /** * Returns the result of calling {@link #getFeatureID()}. * @param expectedClass the class to which the ID is relative. * @return <code>getFeatureID()</code>. */ protected int getFeatureID(Class<?> expectedClass) { return getFeatureID(); } /** * Returns whether the list is considered set, i.e., whether it's not empty. * A derived implementation may model this state directly. * @return whether the list is considered set. */ protected boolean isSet() { return !isEmpty(); } /** * Returns <code>false</code>. * @return <code>false</code>. */ protected boolean hasInverse() { return false; } /** * Returns <code>!{@link #hasInverse()}</code>. * @return <code>!hasInverse</code>. */ @Override protected boolean canContainNull() { return !hasInverse(); } /** * Returns <code>false</code>. * @return <code>false</code>. */ protected boolean isNotificationRequired() { return false; } /** * Returns <code>false</code>. * @return <code>false</code>. */ protected boolean hasShadow() { return false; } /** * Does nothing and returns the <code>notifications</code>. * Clients can override this to update the inverse of a bidirectional relation. * @param object the object that's been added to the list. * @param notifications the chain of accumulating notifications. * @return the <code>notifications</code>. */ protected NotificationChain shadowAdd(E object, NotificationChain notifications) { return notifications; } /** * Does nothing and returns the <code>notifications</code>. * Clients can override this to update the inverse of a bidirectional relation. * @param object the object that's been remove from the list. * @param notifications the chain of accumulating notifications. * @return the <code>notifications</code>. */ protected NotificationChain shadowRemove(E object, NotificationChain notifications) { return notifications; } /** * Does nothing and returns the <code>notifications</code>. * Clients can override this to update the inverse of a bidirectional relation. * @param oldObject the object that's been removed from the list. * @param newObject the object that's been added to the list. * @param notifications the chain of accumulating notifications. * @return the <code>notifications</code>. */ protected NotificationChain shadowSet(E oldObject, E newObject, NotificationChain notifications) { return notifications; } /** * Does nothing and returns the <code>notifications</code>. * Clients can override this to update the inverse of a bidirectional relation. * @param object the object that's been added to the list. * @param notifications the chain of accumulating notifications. * @return the <code>notifications</code>. */ protected NotificationChain inverseAdd(E object, NotificationChain notifications) { return notifications; } /** * Does nothing and returns the <code>notifications</code>. * Clients can override this to update the inverse of a bidirectional relation. * @param object the object that's been remove from the list. * @param notifications the chain of accumulating notifications. * @return the <code>notifications</code>. */ protected NotificationChain inverseRemove(E object, NotificationChain notifications) { return notifications; } /* * @deprecated */ protected NotificationImpl createNotification(int eventType, Object oldObject, Object newObject, int index) { throw new UnsupportedOperationException("Please change your code to call new five argument version of this method"); } /** * Creates a notification. * @param eventType the type of change that has occurred. * @param oldObject the value of the notifier's feature before the change occurred. * @param newObject the value of the notifier's feature after the change occurred. * @param index the position at which the change occurred. * @return a new notification. */ protected NotificationImpl createNotification(int eventType, Object oldObject, Object newObject, int index, boolean wasSet) { return new NotificationImpl(eventType, oldObject, newObject, index, wasSet) { @Override public Object getNotifier() { return DelegatingNotifyingListImpl.this.getNotifier(); } @Override public Object getFeature() { return DelegatingNotifyingListImpl.this.getFeature(); } @Override public int getFeatureID(Class<?> expectedClass) { return DelegatingNotifyingListImpl.this.getFeatureID(expectedClass); } }; } /** * Creates a notification chain, if the expected capacity exceeds the threshold * at which a list is better than chaining individual notification instances. */ protected NotificationChain createNotificationChain(int capacity) { return capacity < 100 ? null: new NotificationChainImpl(capacity); } /** * Dispatches a notification to the notifier of the list. * @param notification the notification to dispatch. */ protected void dispatchNotification(Notification notification) { ((Notifier)getNotifier()).eNotify(notification); } /** * Adds the object at the end of the list; * it does no uniqueness checking. * In addition to the normal effects, * this override implementation generates notifications as {@link #isNotificationRequired required} * and delegates to {@link #inverseAdd inverseAdd} as {@link #hasInverse required}. * @param object the object to be added. * @see #isNotificationRequired * @see #hasInverse * @see #inverseAdd */ @Override public void addUnique(E object) { if (isNotificationRequired()) { int index = size(); boolean oldIsSet = isSet(); doAddUnique(index, object); NotificationImpl notification = createNotification(Notification.ADD, null, object, index, oldIsSet); if (hasInverse()) { NotificationChain notifications = inverseAdd(object, null); if (hasShadow()) { notifications = shadowAdd(object, notifications); } if (notifications == null) { dispatchNotification(notification); } else { notifications.add(notification); notifications.dispatch(); } } else { dispatchNotification(notification); } } else { doAddUnique(object); if (hasInverse()) { NotificationChain notifications = inverseAdd(object, null); if (notifications != null) notifications.dispatch(); } } } /** * Adds the object at the end of the list; * it does no uniqueness checking, inverse updating, or notification. * @param object the object to be added. */ protected void doAddUnique(E object) { super.addUnique(object); } /** * Adds the object at the given index in the list; * it does no ranging checking or uniqueness checking. * In addition to the normal effects, * this override implementation generates notifications as {@link #isNotificationRequired required} * and delegates to {@link #inverseAdd inverseAdd} as {@link #hasInverse required}. * @param object the object to be added. * @see #isNotificationRequired * @see #hasInverse * @see #inverseAdd */ @Override public void addUnique(int index, E object) { if (isNotificationRequired()) { boolean oldIsSet = isSet(); doAddUnique(index, object); NotificationImpl notification = createNotification(Notification.ADD, null, object, index, oldIsSet); if (hasInverse()) { NotificationChain notifications = inverseAdd(object, null); if (hasShadow()) { notifications = shadowAdd(object, notifications); } if (notifications == null) { dispatchNotification(notification); } else { notifications.add(notification); notifications.dispatch(); } } else { dispatchNotification(notification); } } else { doAddUnique(index, object); if (hasInverse()) { NotificationChain notifications = inverseAdd(object, null); if (notifications != null) notifications.dispatch(); } } } /** * Adds the object at the given index in the list; * it does no range checking, uniqueness checking, inverse updating, or notification. * @param object the object to be added. */ protected void doAddUnique(int index, E object) { super.addUnique(index, object); } /** * Adds each object of the collection to the end of the list; * it does no uniqueness checking. * This implementation delegates to {@link #addAllUnique(int, Collection) addAllUnique(int, Collection)}. * @param collection the collection of objects to be added. * @see #inverseAdd */ @Override public boolean addAllUnique(Collection<? extends E> collection) { return addAllUnique(size(), collection); } /** * Adds each object of the collection to the end of the list; * it does no uniqueness checking, inverse updating, or notification. * @param collection the collection of objects to be added. */ protected boolean doAddAllUnique(Collection<? extends E> collection) { return super.addAllUnique(collection);
public NotifyingListImpl(Collection<? extends E> collection) { super(collection); } /** * Returns <code>null</code>. * @return <code>null</code>. */ public Object getNotifier() { return null; } /** * Returns <code>null</code>. * @return <code>null</code>. */ public Object getFeature() { return null; } /** * Returns {@link org.eclipse.emf.common.notify.Notification#NO_FEATURE_ID}. * @return <code>Notification.NO_FEATURE_ID</code>. */ public int getFeatureID() { return Notification.NO_FEATURE_ID; } /** * Returns the result of calling {@link #getFeatureID()}. * @param expectedClass the class to which the ID is relative. * @return <code>getFeatureID()</code>. */ protected int getFeatureID(Class<?> expectedClass) { return getFeatureID(); } /** * Returns whether the list is considered set, i.e., whether it's not empty. * A derived implementation may model this state directly. * @return whether the list is considered set. */ protected boolean isSet() { return !isEmpty(); } /** * Returns <code>false</code>. * @return <code>false</code>. */ protected boolean hasInverse() { return false; } /** * Returns <code>!{@link #hasInverse()}</code>. * @return <code>!hasInverse</code>. */ @Override protected boolean canContainNull() { return !hasInverse(); } /** * Returns <code>false</code>. * @return <code>false</code>. */ protected boolean isNotificationRequired() { return false; } /** * Returns <code>false</code>. * @return <code>false</code>. */ protected boolean hasShadow() { return false; } /** * Does nothing and returns the <code>notifications</code>. * Clients can override this to update the inverse of a bidirectional relation. * @param object the object that's been added to the list. * @param notifications the chain of accumulating notifications. * @return the <code>notifications</code>. */ protected NotificationChain shadowAdd(E object, NotificationChain notifications) { return notifications; } /** * Does nothing and returns the <code>notifications</code>. * Clients can override this to update the inverse of a bidirectional relation. * @param object the object that's been remove from the list. * @param notifications the chain of accumulating notifications. * @return the <code>notifications</code>. */ protected NotificationChain shadowRemove(E object, NotificationChain notifications) { return notifications; } /** * Does nothing and returns the <code>notifications</code>. * Clients can override this to update the inverse of a bidirectional relation. * @param oldObject the object that's been removed from the list. * @param newObject the object that's been added to the list. * @param notifications the chain of accumulating notifications. * @return the <code>notifications</code>. */ protected NotificationChain shadowSet(E oldObject, E newObject, NotificationChain notifications) { return notifications; } /** * Does nothing and returns the <code>notifications</code>. * Clients can override this to update the inverse of a bidirectional relation. * @param object the object that's been added to the list. * @param notifications the chain of accumulating notifications. * @return the <code>notifications</code>. */ protected NotificationChain inverseAdd(E object, NotificationChain notifications) { return notifications; } /** * Does nothing and returns the <code>notifications</code>. * Clients can override this to update the inverse of a bidirectional relation. * @param object the object that's been remove from the list. * @param notifications the chain of accumulating notifications. * @return the <code>notifications</code>. */ protected NotificationChain inverseRemove(E object, NotificationChain notifications) { return notifications; } /* * @deprecated */ protected NotificationImpl createNotification(int eventType, Object oldObject, Object newObject, int index) { throw new UnsupportedOperationException("Please change your code to call new five argument version of this method"); } /** * Creates a notification. * @param eventType the type of change that has occurred. * @param oldObject the value of the notifier's feature before the change occurred. * @param newObject the value of the notifier's feature after the change occurred. * @param index the position at which the change occurred. * @return a new notification. */ protected NotificationImpl createNotification(int eventType, Object oldObject, Object newObject, int index, boolean wasSet) { return new NotificationImpl(eventType, oldObject, newObject, index, wasSet) { @Override public Object getNotifier() { return NotifyingListImpl.this.getNotifier(); } @Override public Object getFeature() { return NotifyingListImpl.this.getFeature(); } @Override public int getFeatureID(Class<?> expectedClass) { return NotifyingListImpl.this.getFeatureID(expectedClass); } }; } /** * Creates a notification chain, if the expected capacity exceeds the threshold * at which a list is better than chaining individual notification instances. */ protected NotificationChain createNotificationChain(int capacity) { return capacity < 100 ? null: new NotificationChainImpl(capacity); } /** * Dispatches a notification to the notifier of the list. * @param notification the notification to dispatch. */ protected void dispatchNotification(Notification notification) { ((Notifier)getNotifier()).eNotify(notification); } /** * Adds the object at the end of the list; * it does no uniqueness checking. * In addition to the normal effects, * this override implementation generates notifications as {@link #isNotificationRequired required} * and delegates to {@link #inverseAdd inverseAdd} as {@link #hasInverse required}. * @param object the object to be added. * @see #isNotificationRequired * @see #hasInverse * @see #inverseAdd */ @Override public void addUnique(E object) { if (isNotificationRequired()) { int index = size; boolean oldIsSet = isSet(); doAddUnique(object); NotificationImpl notification = createNotification(Notification.ADD, null, object, index, oldIsSet); if (hasInverse()) { NotificationChain notifications = inverseAdd(object, null); if (hasShadow()) { notifications = shadowAdd(object, notifications); } if (notifications == null) { dispatchNotification(notification); } else { notifications.add(notification); notifications.dispatch(); } } else { dispatchNotification(notification); } } else { doAddUnique(object); if (hasInverse()) { NotificationChain notifications = inverseAdd(object, null); if (notifications != null) notifications.dispatch(); } } } /** * Adds the object at the end of the list; * it does no uniqueness checking, inverse updating, or notification. * @param object the object to be added. */ protected void doAddUnique(E object) { super.addUnique(object); } /** * Adds the object at the given index in the list; * it does no ranging checking or uniqueness checking. * In addition to the normal effects, * this override implementation generates notifications as {@link #isNotificationRequired required} * and delegates to {@link #inverseAdd inverseAdd} as {@link #hasInverse required}. * @param object the object to be added. * @see #isNotificationRequired * @see #hasInverse * @see #inverseAdd */ @Override public void addUnique(int index, E object) { if (isNotificationRequired()) { boolean oldIsSet = isSet(); doAddUnique(index, object); NotificationImpl notification = createNotification(Notification.ADD, null, object, index, oldIsSet); if (hasInverse()) { NotificationChain notifications = inverseAdd(object, null); if (hasShadow()) { notifications = shadowAdd(object, notifications); } if (notifications == null) { dispatchNotification(notification); } else { notifications.add(notification); notifications.dispatch(); } } else { dispatchNotification(notification); } } else { doAddUnique(index, object); if (hasInverse()) { NotificationChain notifications = inverseAdd(object, null); if (notifications != null) notifications.dispatch(); } } } /** * Adds the object at the given index in the list; * it does no range checking, uniqueness checking, inverse updating, or notification. * @param object the object to be added. */ protected void doAddUnique(int index, E object) { super.addUnique(index, object); } /** * Adds each object of the collection to the end of the list; * it does no uniqueness checking. * This implementation delegates to {@link #addAllUnique(int, Collection) addAllUnique(int, Collection)}. * @param collection the collection of objects to be added. * @see #inverseAdd */ @Override public boolean addAllUnique(Collection<? extends E> collection) { return addAllUnique(size, collection); } /** * Adds each object of the collection to the end of the list; * it does no uniqueness checking, inverse updating, or notification. * @param collection the collection of objects to be added. */ protected boolean doAddAllUnique(Collection<? extends E> collection) { return super.addAllUnique(collection);
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/common/notify/impl/DelegatingNotifyingListImpl.java File path: /emf-2.4.1/src/org/eclipse/emf/common/notify/impl/NotifyingListImpl.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public DelegatingNotifyingListImpl(Collection<? extends E> collection)
1
public NotifyingListImpl(Collection<? extends E> collection)
2
  {
2
  {
3
    super(collection);
3
    super(collection);
4
  }
4
  }
5
  /**
5
  /**
6
   * Returns <code>null</code>.
6
   * Returns <code>null</code>.
7
   * @return <code>null</code>.
7
   * @return <code>null</code>.
8
   */
8
   */
9
  public Object getNotifier()
9
  public Object getNotifier()
10
  {
10
  {
11
    return null;
11
    return null;
12
  }
12
  }
13
  /**
13
  /**
14
   * Returns <code>null</code>.
14
   * Returns <code>null</code>.
15
   * @return <code>null</code>.
15
   * @return <code>null</code>.
16
   */
16
   */
17
  public Object getFeature()
17
  public Object getFeature()
18
  {
18
  {
19
    return null;
19
    return null;
20
  }
20
  }
21
  /**
21
  /**
22
   * Returns {@link Notification#NO_FEATURE_ID}.
22
   * Returns {@link org.eclipse.emf.common.notify.Notification#NO_FEATURE_ID}.
23
   * @return <code>Notification.NO_FEATURE_ID</code>.
23
   * @return <code>Notification.NO_FEATURE_ID</code>.
24
   */
24
   */
25
  public int getFeatureID()
25
  public int getFeatureID()
26
  {
26
  {
27
    return Notification.NO_FEATURE_ID;
27
    return Notification.NO_FEATURE_ID;
28
  }
28
  }
29
  /**
29
  /**
30
   * Returns the result of calling {@link #getFeatureID()}.
30
   * Returns the result of calling {@link #getFeatureID()}.
31
   * @param expectedClass the class to which the ID is relative.
31
   * @param expectedClass the class to which the ID is relative.
32
   * @return <code>getFeatureID()</code>.
32
   * @return <code>getFeatureID()</code>.
33
   */
33
   */
34
  protected int getFeatureID(Class<?> expectedClass)
34
  protected int getFeatureID(Class<?> expectedClass)
35
  {
35
  {
36
    return getFeatureID();
36
    return getFeatureID();
37
  }
37
  }
38
  /**
38
  /**
39
   * Returns whether the list is considered set, i.e., whether it's not empty.
39
   * Returns whether the list is considered set, i.e., whether it's not empty.
40
   * A derived implementation may model this state directly.
40
   * A derived implementation may model this state directly.
41
   * @return whether the list is considered set.
41
   * @return whether the list is considered set.
42
   */
42
   */
43
  protected boolean isSet()
43
  protected boolean isSet()
44
  {
44
  {
45
    return !isEmpty();
45
    return !isEmpty();
46
  }
46
  }
47
  /**
47
  /**
48
   * Returns <code>false</code>.
48
   * Returns <code>false</code>.
49
   * @return <code>false</code>.
49
   * @return <code>false</code>.
50
   */
50
   */
51
  protected boolean hasInverse()
51
  protected boolean hasInverse()
52
  {
52
  {
53
    return false;
53
    return false;
54
  }
54
  }
55
  /**
55
  /**
56
   * Returns <code>!{@link #hasInverse()}</code>.
56
   * Returns <code>!{@link #hasInverse()}</code>.
57
   * @return <code>!hasInverse</code>.
57
   * @return <code>!hasInverse</code>.
58
   */
58
   */
59
  @Override
59
  @Override
60
  protected boolean canContainNull()
60
  protected boolean canContainNull()
61
  {
61
  {
62
    return !hasInverse();
62
    return !hasInverse();
63
  }
63
  }
64
  /**
64
  /**
65
   * Returns <code>false</code>.
65
   * Returns <code>false</code>.
66
   * @return <code>false</code>.
66
   * @return <code>false</code>.
67
   */
67
   */
68
  protected boolean isNotificationRequired()
68
  protected boolean isNotificationRequired()
69
  {
69
  {
70
    return false;
70
    return false;
71
  }
71
  }
72
  /**
72
  /**
73
   * Returns <code>false</code>.
73
   * Returns <code>false</code>.
74
   * @return <code>false</code>.
74
   * @return <code>false</code>.
75
   */
75
   */
76
  protected boolean hasShadow()
76
  protected boolean hasShadow()
77
  {
77
  {
78
    return false;
78
    return false;
79
  }
79
  }
80
  /**
80
  /**
81
   * Does nothing and returns the <code>notifications</code>.
81
   * Does nothing and returns the <code>notifications</code>.
82
   * Clients can override this to update the inverse of a bidirectional relation.
82
   * Clients can override this to update the inverse of a bidirectional relation.
83
   * @param object the object that's been added to the list.
83
   * @param object the object that's been added to the list.
84
   * @param notifications the chain of accumulating notifications.
84
   * @param notifications the chain of accumulating notifications.
85
   * @return the <code>notifications</code>.
85
   * @return the <code>notifications</code>.
86
   */
86
   */
87
  protected NotificationChain shadowAdd(E object, NotificationChain notifications)
87
  protected NotificationChain shadowAdd(E object, NotificationChain notifications)
88
  {
88
  {
89
    return notifications;
89
    return notifications;
90
  }
90
  }
91
  /**
91
  /**
92
   * Does nothing and returns the <code>notifications</code>.
92
   * Does nothing and returns the <code>notifications</code>.
93
   * Clients can override this to update the inverse of a bidirectional relation.
93
   * Clients can override this to update the inverse of a bidirectional relation.
94
   * @param object the object that's been remove from the list.
94
   * @param object the object that's been remove from the list.
95
   * @param notifications the chain of accumulating notifications.
95
   * @param notifications the chain of accumulating notifications.
96
   * @return the <code>notifications</code>.
96
   * @return the <code>notifications</code>.
97
   */
97
   */
98
  protected NotificationChain shadowRemove(E object, NotificationChain notifications)
98
  protected NotificationChain shadowRemove(E object, NotificationChain notifications)
99
  {
99
  {
100
    return notifications;
100
    return notifications;
101
  }
101
  }
102
  /**
102
  /**
103
   * Does nothing and returns the <code>notifications</code>.
103
   * Does nothing and returns the <code>notifications</code>.
104
   * Clients can override this to update the inverse of a bidirectional relation.
104
   * Clients can override this to update the inverse of a bidirectional relation.
105
   * @param oldObject the object that's been removed from the list.
105
   * @param oldObject the object that's been removed from the list.
106
   * @param newObject the object that's been added to the list.
106
   * @param newObject the object that's been added to the list.
107
   * @param notifications the chain of accumulating notifications.
107
   * @param notifications the chain of accumulating notifications.
108
   * @return the <code>notifications</code>.
108
   * @return the <code>notifications</code>.
109
   */
109
   */
110
  protected NotificationChain shadowSet(E oldObject, E newObject, NotificationChain notifications)
110
  protected NotificationChain shadowSet(E oldObject, E newObject, NotificationChain notifications)
111
  {
111
  {
112
    return notifications;
112
    return notifications;
113
  }
113
  }
114
  /**
114
  /**
115
   * Does nothing and returns the <code>notifications</code>.
115
   * Does nothing and returns the <code>notifications</code>.
116
   * Clients can override this to update the inverse of a bidirectional relation.
116
   * Clients can override this to update the inverse of a bidirectional relation.
117
   * @param object the object that's been added to the list.
117
   * @param object the object that's been added to the list.
118
   * @param notifications the chain of accumulating notifications.
118
   * @param notifications the chain of accumulating notifications.
119
   * @return the <code>notifications</code>.
119
   * @return the <code>notifications</code>.
120
   */
120
   */
121
  protected NotificationChain inverseAdd(E object, NotificationChain notifications)
121
  protected NotificationChain inverseAdd(E object, NotificationChain notifications)
122
  {
122
  {
123
    return notifications;
123
    return notifications;
124
  }
124
  }
125
  /**
125
  /**
126
   * Does nothing and returns the <code>notifications</code>.
126
   * Does nothing and returns the <code>notifications</code>.
127
   * Clients can override this to update the inverse of a bidirectional relation.
127
   * Clients can override this to update the inverse of a bidirectional relation.
128
   * @param object the object that's been remove from the list.
128
   * @param object the object that's been remove from the list.
129
   * @param notifications the chain of accumulating notifications.
129
   * @param notifications the chain of accumulating notifications.
130
   * @return the <code>notifications</code>.
130
   * @return the <code>notifications</code>.
131
   */
131
   */
132
  protected NotificationChain inverseRemove(E object, NotificationChain notifications)
132
  protected NotificationChain inverseRemove(E object, NotificationChain notifications)
133
  {
133
  {
134
    return notifications;
134
    return notifications;
135
  }
135
  }
136
  /*
136
  /*
137
   * @deprecated
137
   * @deprecated
138
   */
138
   */
139
  protected NotificationImpl createNotification(int eventType, Object oldObject, Object newObject, int index)
139
  protected NotificationImpl createNotification(int eventType, Object oldObject, Object newObject, int index)
140
  {
140
  {
141
    throw new UnsupportedOperationException("Please change your code to call new five argument version of this method");
141
    throw new UnsupportedOperationException("Please change your code to call new five argument version of this method");
142
  }
142
  }
143
  /**
143
  /**
144
   * Creates a notification.
144
   * Creates a notification.
145
   * @param eventType the type of change that has occurred.
145
   * @param eventType the type of change that has occurred.
146
   * @param oldObject the value of the notifier's feature before the change occurred.
146
   * @param oldObject the value of the notifier's feature before the change occurred.
147
   * @param newObject the value of the notifier's feature after the change occurred.
147
   * @param newObject the value of the notifier's feature after the change occurred.
148
   * @param index the position at which the change occurred.
148
   * @param index the position at which the change occurred.
149
   * @return a new notification.
149
   * @return a new notification.
150
   */
150
   */
151
  protected NotificationImpl createNotification(int eventType, Object oldObject, Object newObject, int index, boolean wasSet)
151
  protected NotificationImpl createNotification(int eventType, Object oldObject, Object newObject, int index, boolean wasSet)
152
  {
152
  {
153
    return 
153
    return 
154
      new NotificationImpl(eventType, oldObject, newObject, index, wasSet)
154
      new NotificationImpl(eventType, oldObject, newObject, index, wasSet)
155
      {
155
      {
156
        @Override
156
        @Override
157
        public Object getNotifier()
157
        public Object getNotifier()
158
        {
158
        {
159
          return DelegatingNotifyingListImpl.this.getNotifier();
159
          return NotifyingListImpl.this.getNotifier();
160
        }
160
        }
161
        @Override
161
        @Override
162
        public Object getFeature()
162
        public Object getFeature()
163
        {
163
        {
164
          return DelegatingNotifyingListImpl.this.getFeature();
164
          return NotifyingListImpl.this.getFeature();
165
        }
165
        }
166
        @Override
166
        @Override
167
        public int getFeatureID(Class<?> expectedClass)
167
        public int getFeatureID(Class<?> expectedClass)
168
        {
168
        {
169
          return DelegatingNotifyingListImpl.this.getFeatureID(expectedClass);
169
          return NotifyingListImpl.this.getFeatureID(expectedClass);
170
        }
170
        }
171
      };
171
      };
172
  }
172
  }
173
  /**
173
  /**
174
   * Creates a notification chain, if the expected capacity exceeds the threshold 
174
   * Creates a notification chain, if the expected capacity exceeds the threshold 
175
   * at which a list is better than chaining individual notification instances.
175
   * at which a list is better than chaining individual notification instances.
176
   */
176
   */
177
  protected NotificationChain createNotificationChain(int capacity)
177
  protected NotificationChain createNotificationChain(int capacity)
178
  {
178
  {
179
    return capacity < 100 ? null: new NotificationChainImpl(capacity);
179
    return capacity < 100 ? null: new NotificationChainImpl(capacity);
180
  }
180
  }
181
  /**
181
  /**
182
   * Dispatches a notification to the notifier of the list.
182
   * Dispatches a notification to the notifier of the list.
183
   * @param notification the notification to dispatch.
183
   * @param notification the notification to dispatch.
184
   */
184
   */
185
  protected void dispatchNotification(Notification notification)
185
  protected void dispatchNotification(Notification notification)
186
  {
186
  {
187
    ((Notifier)getNotifier()).eNotify(notification);
187
    ((Notifier)getNotifier()).eNotify(notification);
188
  }
188
  }
189
  /**
189
  /**
190
   * Adds the object at the end of the list;
190
   * Adds the object at the end of the list;
191
   * it does no uniqueness checking.
191
   * it does no uniqueness checking.
192
   * In addition to the normal effects, 
192
   * In addition to the normal effects, 
193
   * this override implementation generates notifications as {@link #isNotificationRequired required} 
193
   * this override implementation generates notifications as {@link #isNotificationRequired required} 
194
   * and delegates to {@link #inverseAdd inverseAdd} as {@link #hasInverse required}.
194
   * and delegates to {@link #inverseAdd inverseAdd} as {@link #hasInverse required}.
195
   * @param object the object to be added.
195
   * @param object the object to be added.
196
   * @see #isNotificationRequired
196
   * @see #isNotificationRequired
197
   * @see #hasInverse
197
   * @see #hasInverse
198
   * @see #inverseAdd
198
   * @see #inverseAdd
199
   */
199
   */
200
  @Override
200
  @Override
201
  public void addUnique(E object)
201
  public void addUnique(E object)
202
  {
202
  {
203
    if (isNotificationRequired())
203
    if (isNotificationRequired())
204
    {
204
    {
205
      int index = size();
205
      int index = size;
206
      boolean oldIsSet = isSet();
206
      boolean oldIsSet = isSet();
207
      doAddUnique(index, object);
207
      doAddUnique(object);
208
      NotificationImpl notification = createNotification(Notification.ADD, null, object, index, oldIsSet);
208
      NotificationImpl notification = createNotification(Notification.ADD, null, object, index, oldIsSet);
209
      if (hasInverse())
209
      if (hasInverse())
210
      {
210
      {
211
        NotificationChain notifications = inverseAdd(object, null);
211
        NotificationChain notifications = inverseAdd(object, null);
212
        if (hasShadow())
212
        if (hasShadow())
213
        {
213
        {
214
          notifications = shadowAdd(object, notifications);
214
          notifications = shadowAdd(object, notifications);
215
        }
215
        }
216
        if (notifications == null)
216
        if (notifications == null)
217
        {
217
        {
218
          dispatchNotification(notification);
218
          dispatchNotification(notification);
219
        }
219
        }
220
        else
220
        else
221
        {
221
        {
222
          notifications.add(notification);
222
          notifications.add(notification);
223
          notifications.dispatch();
223
          notifications.dispatch();
224
        }
224
        }
225
      }
225
      }
226
      else
226
      else
227
      {
227
      {
228
        dispatchNotification(notification);
228
        dispatchNotification(notification);
229
      }
229
      }
230
    }
230
    }
231
    else
231
    else
232
    {
232
    {
233
      doAddUnique(object);
233
      doAddUnique(object);
234
      if (hasInverse())
234
      if (hasInverse())
235
      {
235
      {
236
        NotificationChain notifications = inverseAdd(object, null);
236
        NotificationChain notifications = inverseAdd(object, null);
237
        if (notifications != null) notifications.dispatch();
237
        if (notifications != null) notifications.dispatch();
238
      }
238
      }
239
    }
239
    }
240
  }
240
  }
241
  /**
241
  /**
242
   * Adds the object at the end of the list;
242
   * Adds the object at the end of the list;
243
   * it does no uniqueness checking, inverse updating, or notification.
243
   * it does no uniqueness checking, inverse updating, or notification.
244
   * @param object the object to be added.
244
   * @param object the object to be added.
245
   */
245
   */
246
  protected void doAddUnique(E object)
246
  protected void doAddUnique(E object)
247
  {
247
  {
248
    super.addUnique(object);
248
    super.addUnique(object);
249
  }
249
  }
250
  /**
250
  /**
251
   * Adds the object at the given index in the list;
251
   * Adds the object at the given index in the list;
252
   * it does no ranging checking or uniqueness checking.
252
   * it does no ranging checking or uniqueness checking.
253
   * In addition to the normal effects, 
253
   * In addition to the normal effects, 
254
   * this override implementation generates notifications as {@link #isNotificationRequired required} 
254
   * this override implementation generates notifications as {@link #isNotificationRequired required} 
255
   * and delegates to {@link #inverseAdd inverseAdd} as {@link #hasInverse required}.
255
   * and delegates to {@link #inverseAdd inverseAdd} as {@link #hasInverse required}.
256
   * @param object the object to be added.
256
   * @param object the object to be added.
257
   * @see #isNotificationRequired
257
   * @see #isNotificationRequired
258
   * @see #hasInverse
258
   * @see #hasInverse
259
   * @see #inverseAdd
259
   * @see #inverseAdd
260
   */
260
   */
261
  @Override
261
  @Override
262
  public void addUnique(int index, E object)
262
  public void addUnique(int index, E object)
263
  {
263
  {
264
    if (isNotificationRequired())
264
    if (isNotificationRequired())
265
    {
265
    {
266
      boolean oldIsSet = isSet();
266
      boolean oldIsSet = isSet();
267
      doAddUnique(index, object);
267
      doAddUnique(index, object);
268
      NotificationImpl notification = createNotification(Notification.ADD, null, object, index, oldIsSet);
268
      NotificationImpl notification = createNotification(Notification.ADD, null, object, index, oldIsSet);
269
      if (hasInverse())
269
      if (hasInverse())
270
      {
270
      {
271
        NotificationChain notifications = inverseAdd(object, null);
271
        NotificationChain notifications = inverseAdd(object, null);
272
        if (hasShadow())
272
        if (hasShadow())
273
        {
273
        {
274
          notifications = shadowAdd(object, notifications);
274
          notifications = shadowAdd(object, notifications);
275
        }
275
        }
276
        if (notifications == null)
276
        if (notifications == null)
277
        {
277
        {
278
          dispatchNotification(notification);
278
          dispatchNotification(notification);
279
        }
279
        }
280
        else
280
        else
281
        {
281
        {
282
          notifications.add(notification);
282
          notifications.add(notification);
283
          notifications.dispatch();
283
          notifications.dispatch();
284
        }
284
        }
285
      }
285
      }
286
      else
286
      else
287
      {
287
      {
288
        dispatchNotification(notification);
288
        dispatchNotification(notification);
289
      }
289
      }
290
    }
290
    }
291
    else
291
    else
292
    {
292
    {
293
      doAddUnique(index, object);
293
      doAddUnique(index, object);
294
      if (hasInverse())
294
      if (hasInverse())
295
      {
295
      {
296
        NotificationChain notifications = inverseAdd(object, null);
296
        NotificationChain notifications = inverseAdd(object, null);
297
        if (notifications != null) notifications.dispatch();
297
        if (notifications != null) notifications.dispatch();
298
      }
298
      }
299
    }
299
    }
300
  }
300
  }
301
  /**
301
  /**
302
   * Adds the object at the given index in the list;
302
   * Adds the object at the given index in the list;
303
   * it does no range checking, uniqueness checking, inverse updating, or notification.
303
   * it does no range checking, uniqueness checking, inverse updating, or notification.
304
   * @param object the object to be added.
304
   * @param object the object to be added.
305
   */
305
   */
306
  protected void doAddUnique(int index, E object)
306
  protected void doAddUnique(int index, E object)
307
  {
307
  {
308
    super.addUnique(index, object);
308
    super.addUnique(index, object);
309
  }
309
  }
310
  /**
310
  /**
311
   * Adds each object of the collection to the end of the list;
311
   * Adds each object of the collection to the end of the list;
312
   * it does no uniqueness checking.
312
   * it does no uniqueness checking.
313
   * This implementation delegates to {@link #addAllUnique(int, Collection) addAllUnique(int, Collection)}.
313
   * This implementation delegates to {@link #addAllUnique(int, Collection) addAllUnique(int, Collection)}.
314
   * @param collection the collection of objects to be added.
314
   * @param collection the collection of objects to be added.
315
   * @see #inverseAdd
315
   * @see #inverseAdd
316
   */
316
   */
317
  @Override
317
  @Override
318
  public boolean addAllUnique(Collection<? extends E> collection)
318
  public boolean addAllUnique(Collection<? extends E> collection)
319
  {
319
  {
320
    return addAllUnique(size(), collection);
320
    return addAllUnique(size, collection);
321
  }
321
  }
322
  /**
322
  /**
323
   * Adds each object of the collection to the end of the list;
323
   * Adds each object of the collection to the end of the list;
324
   * it does no uniqueness checking, inverse updating, or notification.
324
   * it does no uniqueness checking, inverse updating, or notification.
325
   * @param collection the collection of objects to be added.
325
   * @param collection the collection of objects to be added.
326
   */
326
   */
327
  protected boolean doAddAllUnique(Collection<? extends E> collection)
327
  protected boolean doAddAllUnique(Collection<? extends E> collection)
328
  {
328
  {
329
    return super.addAllUnique(collection);
329
    return super.addAllUnique(collection);
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0