Class NotifyingListImpl<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
org.eclipse.emf.common.util.AbstractEList<E>
org.eclipse.emf.common.util.BasicEList<E>
org.eclipse.emf.common.notify.impl.NotifyingListImpl<E>
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<E>,Collection<E>,List<E>,RandomAccess,SequencedCollection<E>,NotifyingList<E>,EList<E>
An extensible implementation of a notifying list.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.emf.common.util.BasicEList
BasicEList.BasicIndexOutOfBoundsException, BasicEList.EIterator<E1>, BasicEList.EListIterator<E1>, BasicEList.FastCompare<E>, BasicEList.NonResolvingEIterator<E1>, BasicEList.NonResolvingEListIterator<E1>, BasicEList.UnmodifiableEList<E> -
Field Summary
Fields inherited from class org.eclipse.emf.common.util.BasicEList
data, sizeFields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty instance.NotifyingListImpl(int initialCapacity) Creates an empty instance with the given capacity.NotifyingListImpl(Collection<? extends E> collection) Creates an instance that is a copy of the collection. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddAllUnique(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.booleanaddAllUnique(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.booleanaddAllUnique(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 uniqueness checking.booleanaddAllUnique(Collection<? extends E> collection) Adds each object of the collection to the end of the list; it does no uniqueness checking.voidAdds the object at the given index in the list; it does no ranging checking or uniqueness checking.voidAdds the object at the end of the list; it does no uniqueness checking.basicAdd(E object, NotificationChain notifications) Adds the object at the end of the list and returns the potentially updated notification chain; it does noinverseupdating.basicRemove(Object object, NotificationChain notifications) Removes the object from the list and returns the potentially updated notification chain; it does noinverseupdating.basicSet(int index, E object, NotificationChain notifications) Sets the object at the index and returns the potentially updated notification chain; it does noinverseupdating.protected booleanReturns!.hasInverse()voidclear()Clears the list of all objects.protected NotificationImplcreateNotification(int eventType, Object oldObject, Object newObject, int index) protected NotificationImplcreateNotification(int eventType, Object oldObject, Object newObject, int index, boolean wasSet) Creates a notification.protected NotificationChaincreateNotificationChain(int capacity) Creates a notification chain, if the expected capacity exceeds the threshold at which a list is better than chaining individual notification instances.protected voiddispatchNotification(Notification notification) Dispatches a notification to the notifier of the list.protected booleandoAddAllUnique(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.protected booleandoAddAllUnique(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.protected booleandoAddAllUnique(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.protected booleandoAddAllUnique(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.protected voiddoAddUnique(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.protected voiddoAddUnique(E object) Adds the object at the end of the list; it does no uniqueness checking, inverse updating, or notification.protected voiddoClear()Clears the list of all objects; it does noinverseupdating.protected EdoMove(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.protected EdoRemove(int index) Removes the object at the index from the list and returns it; it does no inverse updating, or notification.protected booleandoRemoveAll(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.protected EdoSetUnique(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.Returnsnull.intReturnsNotification.NO_FEATURE_ID.protected intgetFeatureID(Class<?> expectedClass) Returns the result of callinggetFeatureID().Returnsnull.protected booleanReturnsfalse.protected booleanReturnsfalse.protected NotificationChaininverseAdd(E object, NotificationChain notifications) Does nothing and returns thenotifications.protected NotificationChaininverseRemove(E object, NotificationChain notifications) Does nothing and returns thenotifications.protected booleanReturnsfalse.protected booleanisSet()Returns whether the list is considered set, i.e., whether it's not empty.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.remove(int index) Removes the object at the index from the list and returns it.booleanremoveAll(Collection<?> collection) Removes each object of the collection from the list and returns whether any object was actually contained by the list.protected EReturns the resolved object from this list for the purpose of testing whetherremoveAll(Collection)applies to it.Sets the object at the index and returns the old object at the index; it does no ranging checking or uniqueness checking.protected NotificationChainshadowAdd(E object, NotificationChain notifications) Does nothing and returns thenotifications.protected NotificationChainshadowRemove(E object, NotificationChain notifications) Does nothing and returns thenotifications.protected NotificationChainshadowSet(E oldObject, E newObject, NotificationChain notifications) Does nothing and returns thenotifications.Methods inherited from class org.eclipse.emf.common.util.BasicEList
assign, basicGet, basicList, clone, contains, data, get, grow, indexOf, isEmpty, lastIndexOf, newData, primitiveGet, setData, shrink, size, toArray, toArrayMethods inherited from class org.eclipse.emf.common.util.AbstractEList
add, add, addAll, addAll, basicIterator, basicListIterator, basicListIterator, didAdd, didChange, didClear, didMove, didRemove, didSet, equalObjects, equals, getDuplicates, getNonDuplicates, hashCode, isUnique, iterator, listIterator, listIterator, move, remove, resolve, retainAll, set, toString, useEquals, validateMethods inherited from class java.util.AbstractList
removeRange, subListMethods inherited from class java.util.AbstractCollection
containsAllMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
add, add, addAll, addAll, addFirst, addLast, contains, containsAll, equals, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeFirst, removeLast, replaceAll, retainAll, reversed, set, size, sort, spliterator, subList, toArray, toArray
-
Constructor Details
-
NotifyingListImpl
public NotifyingListImpl()Creates an empty instance. -
NotifyingListImpl
public NotifyingListImpl(int initialCapacity) Creates an empty instance with the given capacity.- Parameters:
initialCapacity- the initial capacity of the list before it must grow.
-
NotifyingListImpl
Creates an instance that is a copy of the collection.- Parameters:
collection- the initial contents of the list.
-
-
Method Details
-
getNotifier
Returnsnull.- Specified by:
getNotifierin interfaceNotifyingList<E>- Returns:
null.
-
getFeature
Returnsnull.- Specified by:
getFeaturein interfaceNotifyingList<E>- Returns:
null.- See Also:
-
getFeatureID
public int getFeatureID()ReturnsNotification.NO_FEATURE_ID.- Specified by:
getFeatureIDin interfaceNotifyingList<E>- Returns:
Notification.NO_FEATURE_ID.- See Also:
-
getFeatureID
Returns the result of callinggetFeatureID().- 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()Returnsfalse.- Returns:
false.
-
canContainNull
protected boolean canContainNull()Returns!.hasInverse()- Overrides:
canContainNullin classAbstractEList<E>- Returns:
!hasInverse.
-
isNotificationRequired
protected boolean isNotificationRequired()Returnsfalse.- Returns:
false.
-
hasShadow
protected boolean hasShadow()Returnsfalse.- Returns:
false.
-
shadowAdd
Does nothing and returns thenotifications. 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
Does nothing and returns thenotifications. 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
Does nothing and returns thenotifications. 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
Does nothing and returns thenotifications. 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
Does nothing and returns thenotifications. 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
Creates a notification chain, if the expected capacity exceeds the threshold at which a list is better than chaining individual notification instances. -
dispatchNotification
Dispatches a notification to the notifier of the list.- Parameters:
notification- the notification to dispatch.
-
addUnique
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 asrequiredand delegates toinverseAddasrequired.- Overrides:
addUniquein classBasicEList<E>- Parameters:
object- the object to be added.- See Also:
-
doAddUnique
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
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 asrequiredand delegates toinverseAddasrequired.- Overrides:
addUniquein classBasicEList<E>- Parameters:
object- the object to be added.- See Also:
-
doAddUnique
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
Adds each object of the collection to the end of the list; it does no uniqueness checking. This implementation delegates toaddAllUnique(int, Collection).- Overrides:
addAllUniquein classBasicEList<E>- Parameters:
collection- the collection of objects to be added.- See Also:
-
doAddAllUnique
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
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 asrequiredand delegates toinverseAddasrequired.- Overrides:
addAllUniquein classBasicEList<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
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
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 uniqueness checking. This implementation delegates toaddAllUnique(int, Object[], int, int).- Overrides:
addAllUniquein classBasicEList<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
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
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. This implementation delegates toassign,didAdd, anddidChange. In addition to the normal effects, this override implementation generates notifications asrequiredand delegates toinverseAddasrequired.- Overrides:
addAllUniquein classBasicEList<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
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
Adds the object at the end of the list and returns the potentially updated notification chain; it does noinverseupdating. This implementation generates notifications asrequired.- Parameters:
object- the object to be added.- Returns:
- the notification chain.
- See Also:
-
remove
Removes the object at the index from the list and returns it. In addition to the normal effects, this override implementation generates notifications asrequiredand delegates toinverseRemoveasrequired.- Specified by:
removein interfaceList<E>- Overrides:
removein classBasicEList<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
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
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 asrequiredand delegates toinverseRemoveasrequired.- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceList<E>- Overrides:
removeAllin classAbstractEList<E>- Parameters:
collection- the collection of objects to be removed.- Returns:
- whether any object was actually contained by the list.
- See Also:
-
resolve
Returns the resolved object from this list for the purpose of testing whetherremoveAll(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
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
Removes the object from the list and returns the potentially updated notification chain; it does noinverseupdating. This implementation generates notifications asrequired.- 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 asrequiredand delegates toinverseRemoveasrequired.- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceList<E>- Overrides:
clearin classBasicEList<E>- See Also:
-
doClear
protected void doClear()Clears the list of all objects; it does noinverseupdating. -
setUnique
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 asrequiredand delegates toinverseAddandinverseRemoveasrequired.- Overrides:
setUniquein classBasicEList<E>- Parameters:
index- the position in question.object- the object to set.- Returns:
- the old object at the index.
- See Also:
-
doSetUnique
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
Sets the object at the index and returns the potentially updated notification chain; it does noinverseupdating. This implementation generates notifications asrequired.- Parameters:
index- the position in question.object- the object to set.- Returns:
- the notification chain.
- See Also:
-
move
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 asrequired.- Specified by:
movein interfaceEList<E>- Overrides:
movein classBasicEList<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
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.
-