/**
* Clears the list of all objects;
* it does no {@link #inverseRemove inverse} updating.
*/
protected void doClear() {
super.clear();
}
/**
* Sets the object at the index
* and returns the old object at the index;
* 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} and {@link #inverseRemove inverseRemove} as {@link #hasInverse required}.
* @param index the position in question.
* @param object the object to set.
* @return the old object at the index.
* @see #isNotificationRequired
* @see #hasInverse
* @see #inverseAdd
* @see #inverseRemove
*/
@Override public E setUnique(int index, E object) {
if (isNotificationRequired()) {
NotificationChain notifications = null;
boolean oldIsSet = isSet();
E oldObject;
Notification notification = createNotification(Notification.SET, oldObject = doSetUnique(index, object), object, index, oldIsSet);
if (hasInverse() && !equalObjects(oldObject, object)) {
if (oldObject != null) {
notifications = inverseRemove(oldObject, notifications);
}
notifications = inverseAdd(object, notifications);
if (hasShadow()) {
notifications = shadowSet(oldObject, object, notifications);
}
if (notifications == null) {
dispatchNotification(notification);
}
else {
notifications.add(notification);
notifications.dispatch();
}
}
else {
if (hasShadow()) {
notifications = shadowSet(oldObject, object, notifications);
}
if (notifications == null) {
dispatchNotification(notification);
}
else {
notifications.add(notification);
notifications.dispatch();
}
}
return oldObject;
}
else {
E oldObject = doSetUnique(index, object);
if (hasInverse() && !equalObjects(oldObject, object)) {
NotificationChain notifications = null;
if (oldObject != null) {
notifications = inverseRemove(oldObject, null);
}
notifications = inverseAdd(object, notifications);
if (notifications != null)
notifications.dispatch();
}
return oldObject;
}
}
/**
* Sets the object at the index
* and returns the old object at the index;
* it does no ranging checking, uniqueness checking, inverse updating or notification.
* @param index the position in question.
* @param object the object to set.
* @return the old object at the index.
*/
protected E doSetUnique(int index, E object) {
return super.setUnique(index, object);
}
/**
* Sets the object at the index
* and returns the potentially updated notification chain;
* it does no {@link #hasInverse inverse} updating.
* This implementation generates notifications as {@link #isNotificationRequired required}.
* @param index the position in question.
* @param object the object to set.
* @return the notification chain.
* @see #isNotificationRequired
* @see #hasInverse
* @see #inverseAdd
* @see #inverseRemove
*/
public NotificationChain basicSet(int index, E object, NotificationChain notifications) {
if (isNotificationRequired()) {
boolean oldIsSet = isSet();
NotificationImpl notification = createNotification(Notification.SET, doSetUnique(index, object), object, index, oldIsSet);
if (notifications == null) {
notifications = notification;
}
else {
notifications.add(notification);
}
}
else {
doSetUnique(index, object);
}
return notifications;
}
/**
* Moves the object at the source index of the list to the target index of the list
* and returns the moved object.
* In addition to the normal effects,
* this override implementation generates notifications as {@link #isNotificationRequired required}.
* @param targetIndex the new position for the object in the list.
* @param sourceIndex the old position of the object in the list.
* @return the moved object.
* @exception IndexOutOfBoundsException if either index isn't within the size range.
* @see #isNotificationRequired
*/
@Override public E move(int targetIndex, int sourceIndex) {
if (isNotificationRequired()) {
boolean oldIsSet = isSet();
E object = doMove(targetIndex, sourceIndex);
dispatchNotification(createNotification(Notification.MOVE, sourceIndex, object, targetIndex, oldIsSet));
return object;
}
else {
return doMove(targetIndex, sourceIndex);
}
}
/**
* Moves the object at the source index of the list to the target index of the list
* and returns the moved object;
* it does no notification.
* @param targetIndex the new position for the object in the list.
* @param sourceIndex the old position of the object in the list.
* @return the moved object.
* @exception IndexOutOfBoundsException if either index isn't within the size range.
*/
protected E doMove(int targetIndex, int sourceIndex) {
return super.move(targetIndex, sourceIndex);
}
|