Class DelegatingNotifyingListImpl<E>

All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, NotifyingList<E>, EList<E>

public abstract class DelegatingNotifyingListImpl<E> extends DelegatingEList<E> implements NotifyingList<E>
An extensible implementation of a notifying list that delegates to a backing list.
See Also:
  • Constructor Details

    • DelegatingNotifyingListImpl

      public DelegatingNotifyingListImpl()
      Creates an empty instance.
    • DelegatingNotifyingListImpl

      public DelegatingNotifyingListImpl(Collection<? extends E> collection)
      Creates an instance that is a copy of the collection.
      Parameters:
      collection - the initial contents of the list.
  • Method Details

    • getNotifier

      public Object getNotifier()
      Returns null.
      Specified by:
      getNotifier in interface NotifyingList<E>
      Returns:
      null.
    • getFeature

      public Object getFeature()
      Returns null.
      Specified by:
      getFeature in interface NotifyingList<E>
      Returns:
      null.
      See Also:
    • getFeatureID

      public int getFeatureID()
      Specified by:
      getFeatureID in interface NotifyingList<E>
      Returns:
      Notification.NO_FEATURE_ID.
      See Also:
    • getFeatureID

      protected int getFeatureID(Class<?> expectedClass)
      Returns the result of calling getFeatureID().
      Parameters:
      expectedClass - the class to which the ID is relative.
      Returns:
      getFeatureID().
    • isSet

      protected boolean isSet()
      Returns whether the list is considered set, i.e., whether it's not empty. A derived implementation may model this state directly.
      Returns:
      whether the list is considered set.
    • hasInverse

      protected boolean hasInverse()
      Returns false.
      Returns:
      false.
    • canContainNull

      protected boolean canContainNull()
      Returns !hasInverse().
      Overrides:
      canContainNull in class AbstractEList<E>
      Returns:
      !hasInverse.
    • isNotificationRequired

      protected boolean isNotificationRequired()
      Returns false.
      Returns:
      false.
    • hasShadow

      protected boolean hasShadow()
      Returns false.
      Returns:
      false.
    • shadowAdd

      protected NotificationChain shadowAdd(E object, NotificationChain notifications)
      Does nothing and returns the notifications. Clients can override this to update the inverse of a bidirectional relation.
      Parameters:
      object - the object that's been added to the list.
      notifications - the chain of accumulating notifications.
      Returns:
      the notifications.
    • shadowRemove

      protected NotificationChain shadowRemove(E object, NotificationChain notifications)
      Does nothing and returns the notifications. Clients can override this to update the inverse of a bidirectional relation.
      Parameters:
      object - the object that's been remove from the list.
      notifications - the chain of accumulating notifications.
      Returns:
      the notifications.
    • shadowSet

      protected NotificationChain shadowSet(E oldObject, E newObject, NotificationChain notifications)
      Does nothing and returns the notifications. Clients can override this to update the inverse of a bidirectional relation.
      Parameters:
      oldObject - the object that's been removed from the list.
      newObject - the object that's been added to the list.
      notifications - the chain of accumulating notifications.
      Returns:
      the notifications.
    • inverseAdd

      protected NotificationChain inverseAdd(E object, NotificationChain notifications)
      Does nothing and returns the notifications. Clients can override this to update the inverse of a bidirectional relation.
      Parameters:
      object - the object that's been added to the list.
      notifications - the chain of accumulating notifications.
      Returns:
      the notifications.
    • inverseRemove

      protected NotificationChain inverseRemove(E object, NotificationChain notifications)
      Does nothing and returns the notifications. Clients can override this to update the inverse of a bidirectional relation.
      Parameters:
      object - the object that's been remove from the list.
      notifications - the chain of accumulating notifications.
      Returns:
      the notifications.
    • createNotification

      protected NotificationImpl createNotification(int eventType, Object oldObject, Object newObject, int index)
    • createNotification

      protected NotificationImpl createNotification(int eventType, Object oldObject, Object newObject, int index, boolean wasSet)
      Creates a notification.
      Parameters:
      eventType - the type of change that has occurred.
      oldObject - the value of the notifier's feature before the change occurred.
      newObject - the value of the notifier's feature after the change occurred.
      index - the position at which the change occurred.
      Returns:
      a new notification.
    • createNotificationChain

      protected NotificationChain createNotificationChain(int capacity)
      Creates a notification chain, if the expected capacity exceeds the threshold at which a list is better than chaining individual notification instances.
    • dispatchNotification

      protected void dispatchNotification(Notification notification)
      Dispatches a notification to the notifier of the list.
      Parameters:
      notification - the notification to dispatch.
    • addUnique

      public void addUnique(E object)
      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 required and delegates to inverseAdd as required.
      Overrides:
      addUnique in class DelegatingEList<E>
      Parameters:
      object - the object to be added.
      See Also:
    • doAddUnique

      protected void doAddUnique(E object)
      Adds the object at the end of the list; it does no uniqueness checking, inverse updating, or notification.
      Parameters:
      object - the object to be added.
    • addUnique

      public void addUnique(int index, E 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 required and delegates to inverseAdd as required.
      Overrides:
      addUnique in class DelegatingEList<E>
      Parameters:
      object - the object to be added.
      See Also:
    • doAddUnique

      protected void doAddUnique(int index, E object)
      Adds the object at the given index in the list; it does no range checking, uniqueness checking, inverse updating, or notification.
      Parameters:
      object - the object to be added.
    • addAllUnique

      public boolean addAllUnique(Collection<? extends E> collection)
      Adds each object of the collection to the end of the list; it does no uniqueness checking. This implementation delegates to addAllUnique(int, Collection).
      Overrides:
      addAllUnique in class DelegatingEList<E>
      Parameters:
      collection - the collection of objects to be added.
      See Also:
    • doAddAllUnique

      protected boolean doAddAllUnique(Collection<? extends E> collection)
      Adds each object of the collection to the end of the list; it does no uniqueness checking, inverse updating, or notification.
      Parameters:
      collection - the collection of objects to be added.
    • addAllUnique

      public boolean addAllUnique(int index, Collection<? extends E> collection)
      Adds each object of the collection at each successive index in the list and returns whether any objects were added; it does no ranging checking or uniqueness checking. In addition to the normal effects, this override implementation generates notifications as required and delegates to inverseAdd as required.
      Overrides:
      addAllUnique in class DelegatingEList<E>
      Parameters:
      index - the index at which to add.
      collection - the collection of objects to be added.
      Returns:
      whether any objects were added.
      See Also:
    • doAddAllUnique

      protected boolean doAddAllUnique(int index, Collection<? extends E> collection)
      Adds each object of the collection at each successive index in the list and returns whether any objects were added; it does no range checking, uniqueness checking, inverse updating, or notification.
      Parameters:
      index - the index at which to add.
      collection - the collection of objects to be added.
      Returns:
      whether any objects were added.
    • addAllUnique

      public boolean addAllUnique(Object[] objects, int start, int end)
      Adds each object from start to end of the array to the end of the list; it does no uniqueness checking. This implementation delegates to addAllUnique(int, Object[], int, int).
      Overrides:
      addAllUnique in class DelegatingEList<E>
      Parameters:
      objects - the objects to be added.
      start - the index of first object to be added.
      end - the index past the last object to be added.
      Returns:
      whether any objects were added.
      See Also:
    • doAddAllUnique

      protected boolean doAddAllUnique(Object[] objects, int start, int end)
      Adds each object from start to end of the array to the end of the list and returns whether any objects were added; it does no ranging checking, uniqueness checking, inverse updating, or notification.
      Parameters:
      objects - the objects to be added.
      start - the index of first object to be added.
      end - the index past the last object to be added.
      Returns:
      whether any objects were added.
    • addAllUnique

      public boolean addAllUnique(int index, Object[] objects, int start, int end)
      Adds each object from start to end of the array at each successive index in the list and returns whether any objects were added; it does no ranging checking or uniqueness checking. In addition to the normal effects, this override implementation generates notifications as required and delegates to inverseAdd as required.
      Overrides:
      addAllUnique in class DelegatingEList<E>
      Parameters:
      index - the index at which to add.
      objects - the objects to be added.
      start - the index of first object to be added.
      end - the index past the last object to be added.
      Returns:
      whether any objects were added.
      See Also:
    • doAddAllUnique

      protected boolean doAddAllUnique(int index, Object[] objects, int start, int end)
      Adds each object from start to end of the array at each successive index in the list and returns whether any objects were added; it does no ranging checking, uniqueness checking, inverse updating, or notification.
      Parameters:
      index - the index at which to add.
      objects - the objects to be added.
      start - the index of first object to be added.
      end - the index past the last object to be added.
      Returns:
      whether any objects were added.
    • basicAdd

      public NotificationChain basicAdd(E object, NotificationChain notifications)
      Adds the object at the end of the list and returns the potentially updated notification chain; it does no inverse updating. This implementation generates notifications as required.
      Parameters:
      object - the object to be added.
      Returns:
      the notification chain.
      See Also:
    • remove

      public E remove(int index)
      Removes the object at the index from the list and returns it. In addition to the normal effects, this override implementation generates notifications as required and delegates to inverseRemove as required.
      Specified by:
      remove in interface List<E>
      Overrides:
      remove in class DelegatingEList<E>
      Parameters:
      index - the position of the object to remove.
      Returns:
      the removed object.
      Throws:
      IndexOutOfBoundsException - if the index isn't within the size range.
      See Also:
    • doRemove

      protected E doRemove(int index)
      Removes the object at the index from the list and returns it; it does no inverse updating, or notification.
      Parameters:
      index - the position of the object to remove.
      Returns:
      the removed object.
      Throws:
      IndexOutOfBoundsException - if the index isn't within the size range.
    • removeAll

      public boolean removeAll(Collection<?> collection)
      Removes each object of the collection from the list and returns whether any object was actually contained by the list. In addition to the normal effects, this override implementation generates notifications as required and delegates to inverseRemove as required.
      Specified by:
      removeAll in interface Collection<E>
      Specified by:
      removeAll in interface List<E>
      Overrides:
      removeAll in class DelegatingEList<E>
      Parameters:
      collection - the collection of objects to be removed.
      Returns:
      whether any object was actually contained by the list.
      See Also:
    • resolve

      protected E resolve(E object)
      Returns the resolved object from this list for the purpose of testing whether removeAll(Collection) applies to it.
      Parameters:
      object - the object to be resolved.
      Returns:
      the resolved object from this list for the purpose of testing whether removeAll applies to it.
    • doRemoveAll

      protected boolean doRemoveAll(Collection<?> collection)
      Removes each object of the collection from the list and returns whether any object was actually contained by the list; it does no inverse updating, or notification.
      Parameters:
      collection - the collection of objects to be removed.
      Returns:
      whether any object was actually contained by the list.
    • basicRemove

      public NotificationChain basicRemove(Object object, NotificationChain notifications)
      Removes the object from the list and returns the potentially updated notification chain; it does no inverse updating. This implementation generates notifications as required.
      Parameters:
      object - the object to be removed.
      Returns:
      the notification chain.
      See Also:
    • clear

      public void clear()
      Clears the list of all objects. In addition to the normal effects, this override implementation generates notifications as required and delegates to inverseRemove as required.
      Specified by:
      clear in interface Collection<E>
      Specified by:
      clear in interface List<E>
      Overrides:
      clear in class DelegatingEList<E>
      See Also:
    • doClear

      protected void doClear()
      Clears the list of all objects; it does no inverse updating.
    • setUnique

      public E setUnique(int index, E object)
      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 required and delegates to inverseAdd and inverseRemove as required.
      Overrides:
      setUnique in class DelegatingEList<E>
      Parameters:
      index - the position in question.
      object - the object to set.
      Returns:
      the old object at the index.
      See Also:
    • doSetUnique

      protected E doSetUnique(int index, E object)
      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.
      Parameters:
      index - the position in question.
      object - the object to set.
      Returns:
      the old object at the index.
    • basicSet

      public NotificationChain basicSet(int index, E object, NotificationChain notifications)
      Sets the object at the index and returns the potentially updated notification chain; it does no inverse updating. This implementation generates notifications as required.
      Parameters:
      index - the position in question.
      object - the object to set.
      Returns:
      the notification chain.
      See Also:
    • move

      public E move(int targetIndex, int sourceIndex)
      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 required.
      Specified by:
      move in interface EList<E>
      Overrides:
      move in class DelegatingEList<E>
      Parameters:
      targetIndex - the new position for the object in the list.
      sourceIndex - the old position of the object in the list.
      Returns:
      the moved object.
      Throws:
      IndexOutOfBoundsException - if either index isn't within the size range.
      See Also:
    • doMove

      protected E doMove(int targetIndex, int 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.
      Parameters:
      targetIndex - the new position for the object in the list.
      sourceIndex - the old position of the object in the list.
      Returns:
      the moved object.
      Throws:
      IndexOutOfBoundsException - if either index isn't within the size range.