Package org.eclipse.emf.common.util
Class DelegatingEList<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
org.eclipse.emf.common.util.AbstractEList<E>
org.eclipse.emf.common.util.DelegatingEList<E>
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<E>,Collection<E>,List<E>,EList<E>
- Direct Known Subclasses:
DelegatingEList.UnmodifiableEList,DelegatingNotifyingListImpl
public abstract class DelegatingEList<E>
extends AbstractEList<E>
implements Cloneable, Serializable
A highly extensible delegating list implementation.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classDeprecated.protected classDeprecated.protected classDeprecated.protected classDeprecated.static classAn unmodifiable version ofDelegatingEList.Nested classes/interfaces inherited from class org.eclipse.emf.common.util.AbstractEList
AbstractEList.BasicIndexOutOfBoundsException -
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty instance.DelegatingEList(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 at the index of list and returns whether any objects were added; it does no ranging checking or 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.protected EbasicGet(int index) Returns the object at the index withoutresolvingit.Returns an unsafe list that provides anon-resolvingview of the backing store list.voidclear()Clears the list of all objects.booleanReturns whether the list contains the object.booleancontainsAll(Collection<?> collection) Returns whether the list contains each object in the collection.protected voiddelegateAdd(int index, E object) Adds the object at the given index in the backing store list.protected voiddelegateAdd(E object) Adds the object at the end of the backing store list.Returns an unsafe list that provides anon-resolvingview of the backing store list.protected voidClears the backing store list of all objects.protected booleandelegateContains(Object object) Returns whether the backing store list contains the object.protected booleandelegateContainsAll(Collection<?> collection) Returns whether the backing store list contains each object in the collection.protected booleandelegateEquals(Object object) Returns whether the object is a list with corresponding equal objects to those in the backing store list.protected EdelegateGet(int index) Returns the object at the index in the backing store list.protected intReturns the hash code of the backing store list.protected intdelegateIndexOf(Object object) Returns the position of the first occurrence of the object in the backing store list.protected booleanReturns whether the backing store list has zero size.Returns an iterator over the backing store list.protected intdelegateLastIndexOf(Object object) Returns the position of the last occurrence of the object in the backing store list.Returns the list that acts as the backing store.protected ListIterator<E>Returns a list iterator over the backing store list.protected EdelegateMove(int targetIndex, int sourceIndex) Moves the object at the source index in the backing store list by removing it and adding it at the new target index.protected EdelegateRemove(int index) Removes the object at the index from the backing store list and returns it.protected EdelegateSet(int index, E object) Sets the object at the index in the backing store list and returns the old object at the index.protected intReturns the number of objects in the backing store list.protected Object[]Returns an array containing all the objects in the backing store list in sequence.protected <T> T[]delegateToArray(T[] array) Returns an array containing all the objects in the backing store list in sequence.protected StringReturns a the string form of the backing store list.protected voidDoes the actual job of clearing all the objects.booleanReturns whether the object is a list with corresponding equal objects.get(int index) Returns the object at the index.inthashCode()Returns a hash code computed from each object's hash code.intReturns the position of the first occurrence of the object in the list.booleanisEmpty()Returns whether the list has zero size.intlastIndexOf(Object object) Returns the position of the last occurrence of the object in the list.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.protected EprimitiveGet(int index) Returns the object at the index withoutresolvingit and without range checking the index.remove(int index) Removes the object at the index from the list and returns it.booleanRemoves the object from the list and returns whether the object was actually contained by the list.booleanremoveAll(Collection<?> collection) Removes each object of the collection from the list and returns whether any object was actually contained by the list.booleanretainAll(Collection<?> collection) Removes from the list each object not contained by the collection and returns whether any object was actually removed.Sets the object at the index and returns the old object at the index; it does no ranging checking or uniqueness checking.intsize()Returns the number of objects in the list.Object[]toArray()Returns an array containing all the objects in sequence.<T> T[]toArray(T[] array) Returns an array containing all the objects in sequence.toString()Returns a string of the form"[object1, object2]".Methods inherited from class org.eclipse.emf.common.util.AbstractEList
add, add, addAll, addAll, basicIterator, basicListIterator, basicListIterator, canContainNull, didAdd, didChange, didClear, didMove, didRemove, didSet, equalObjects, getDuplicates, getNonDuplicates, isUnique, iterator, listIterator, listIterator, move, resolve, set, useEquals, validateMethods inherited from class java.util.AbstractList
removeRange, subListMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
replaceAll, sort, spliterator, subList
-
Constructor Details
-
DelegatingEList
public DelegatingEList()Creates an empty instance. -
DelegatingEList
Creates an instance that is a copy of the collection.- Parameters:
collection- the initial contents of the list.
-
-
Method Details
-
delegateList
Returns the list that acts as the backing store.- Returns:
- the list that acts as the backing store.
-
size
public int size()Returns the number of objects in the list.- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceList<E>- Specified by:
sizein classAbstractCollection<E>- Returns:
- the number of objects in the list.
-
delegateSize
protected int delegateSize()Returns the number of objects in the backing store list.- Returns:
- the number of objects in the backing store list.
-
isEmpty
public boolean isEmpty()Returns whether the list has zero size.- Specified by:
isEmptyin interfaceCollection<E>- Specified by:
isEmptyin interfaceList<E>- Overrides:
isEmptyin classAbstractCollection<E>- Returns:
- whether the list has zero size.
-
delegateIsEmpty
protected boolean delegateIsEmpty()Returns whether the backing store list has zero size.- Returns:
- whether the backing store list has zero size.
-
contains
Returns whether the list contains the object.- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceList<E>- Overrides:
containsin classAbstractCollection<E>- Parameters:
object- the object in question.- Returns:
- whether the list contains the object.
-
delegateContains
Returns whether the backing store list contains the object.- Parameters:
object- the object in question.- Returns:
- whether the backing store list contains the object.
-
containsAll
Returns whether the list contains each object in the collection.- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>- Overrides:
containsAllin classAbstractCollection<E>- Returns:
- whether the list contains each object in the collection.
- See Also:
-
delegateContainsAll
Returns whether the backing store list contains each object in the collection.- Returns:
- whether the backing store list contains each object in the collection.
- See Also:
-
indexOf
Returns the position of the first occurrence of the object in the list. -
delegateIndexOf
Returns the position of the first occurrence of the object in the backing store list.- Parameters:
object- the object in question.- Returns:
- the position of the first occurrence of the object in the backing store list.
-
lastIndexOf
Returns the position of the last occurrence of the object in the list.- Specified by:
lastIndexOfin interfaceList<E>- Overrides:
lastIndexOfin classAbstractList<E>- Parameters:
object- the object in question.- Returns:
- the position of the last occurrence of the object in the list.
-
delegateLastIndexOf
Returns the position of the last occurrence of the object in the backing store list.- Parameters:
object- the object in question.- Returns:
- the position of the last occurrence of the object in the backing store list.
-
toArray
Returns an array containing all the objects in sequence.- Specified by:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceList<E>- Overrides:
toArrayin classAbstractCollection<E>- Returns:
- an array containing all the objects in sequence.
-
delegateToArray
Returns an array containing all the objects in the backing store list in sequence.- Returns:
- an array containing all the objects in the backing store list in sequence.
-
toArray
public <T> T[] toArray(T[] array) Returns an array containing all the objects in sequence.- Specified by:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceList<E>- Overrides:
toArrayin classAbstractCollection<E>- Parameters:
array- the array that will be filled and returned, if it's big enough; otherwise, a suitably large array of the same type will be allocated and used instead.- Returns:
- an array containing all the objects in sequence.
-
delegateToArray
protected <T> T[] delegateToArray(T[] array) Returns an array containing all the objects in the backing store list in sequence.- Parameters:
array- the array that will be filled and returned, if it's big enough; otherwise, a suitably large array of the same type will be allocated and used instead.- Returns:
- an array containing all the objects in sequence.
-
get
Returns the object at the index. This implementation delegates toresolveso that clients may transform the fetched object.- Specified by:
getin interfaceList<E>- Specified by:
getin classAbstractList<E>- Parameters:
index- the position in question.- Returns:
- the object at the index.
- Throws:
IndexOutOfBoundsException- if the index isn't within the size range.- See Also:
-
delegateGet
Returns the object at the index in the backing store list.- Parameters:
index- the position in question.- Returns:
- the object at the index.
- Throws:
IndexOutOfBoundsException- if the index isn't within the size range.
-
basicGet
Returns the object at the index withoutresolvingit.- Overrides:
basicGetin classAbstractEList<E>- Parameters:
index- the position in question.- Returns:
- the object at the index.
- Throws:
IndexOutOfBoundsException- if the index isn't within the size range.- See Also:
-
primitiveGet
Description copied from class:AbstractEListReturns the object at the index withoutresolvingit and without range checking the index.- Specified by:
primitiveGetin classAbstractEList<E>- Parameters:
index- the position in question.- Returns:
- the object at the index.
- See Also:
-
setUnique
Sets the object at the index and returns the old object at the index; it does no ranging checking or uniqueness checking. This implementation delegates todidSetanddidChange.- Specified by:
setUniquein classAbstractEList<E>- Parameters:
index- the position in question.object- the object to set.- Returns:
- the old object at the index.
- See Also:
-
delegateSet
Sets the object at the index in the backing store list and returns the old object at the index.- Parameters:
object- the object to set.- Returns:
- the old object at the index.
-
addUnique
Adds the object at the end of the list; it does no uniqueness checking. This implementation delegates todidAddanddidChange. after uniqueness checking.- Specified by:
addUniquein classAbstractEList<E>- Parameters:
object- the object to be added.- See Also:
-
delegateAdd
Adds the object at the end of the backing store list.- 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. This implementation delegates todidAddanddidChange.- Specified by:
addUniquein classAbstractEList<E>- Parameters:
object- the object to be added.- See Also:
-
delegateAdd
Adds the object at the given index in the backing store list.- 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 todidAddanddidChange.- Specified by:
addAllUniquein classAbstractEList<E>- Parameters:
collection- the collection of objects to be added.- See Also:
-
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. This implementation delegates todidAddanddidChange.- Specified by:
addAllUniquein classAbstractEList<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:
-
addAllUnique
Adds each object from start to end of the array at the index of list and returns whether any objects were added; it does no ranging checking or uniqueness checking. This implementation delegates todelegatedAdd,didAdd, anddidChange.- Specified by:
addAllUniquein classAbstractEList<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:
-
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 todelegatedAdd,didAdd, anddidChange.- Specified by:
addAllUniquein classAbstractEList<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:
-
remove
Removes the object from the list and returns whether the object was actually contained by the list. This implementation usesindexOfto find the object and delegates toremove(int)in the case that it finds the object.- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceList<E>- Overrides:
removein classAbstractEList<E>- Parameters:
object- the object to be removed.- Returns:
- whether the object was actually contained by the list.
-
removeAll
Removes each object of the collection from the list and returns whether any object was actually contained by the list.- 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.
-
remove
Removes the object at the index from the list and returns it. This implementation delegates todidRemoveanddidChange.- Specified by:
removein interfaceList<E>- Specified by:
removein classAbstractEList<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.
-
delegateRemove
Removes the object at the index from the backing store list and returns it.- Returns:
- the removed object.
- Throws:
IndexOutOfBoundsException- if the index isn't within the size range.
-
retainAll
Removes from the list each object not contained by the collection and returns whether any object was actually removed. This delegates toremove(int)in the case that it finds an object that isn't retained.- Specified by:
retainAllin interfaceCollection<E>- Specified by:
retainAllin interfaceList<E>- Overrides:
retainAllin classAbstractEList<E>- Parameters:
collection- the collection of objects to be retained.- Returns:
- whether any object was actually removed.
-
clear
public void clear()Clears the list of all objects.- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceList<E>- Overrides:
clearin classAbstractList<E>
-
doClear
Does the actual job of clearing all the objects.- Parameters:
oldSize- the size of the list before it is cleared.oldData- old values of the list before it is cleared.
-
delegateClear
protected void delegateClear()Clears the backing store list of all objects. -
move
Moves the object at the source index of the list to the target index of the list and returns the moved object. This implementation delegates todidMoveanddidChange.- Specified by:
movein interfaceEList<E>- Specified by:
movein classAbstractEList<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.
-
delegateMove
Moves the object at the source index in the backing store list by removing it and adding it at the new target index.- 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.- Since:
- 2.3
-
equals
Returns whether the object is a list with corresponding equal objects. This implementation uses eitherequalsor"=="depending onuseEquals.- Specified by:
equalsin interfaceCollection<E>- Specified by:
equalsin interfaceList<E>- Overrides:
equalsin classAbstractEList<E>- Returns:
- whether the object is a list with corresponding equal objects.
- See Also:
-
delegateEquals
Returns whether the object is a list with corresponding equal objects to those in the backing store list.- Returns:
- whether the object is a list with corresponding equal objects.
-
hashCode
public int hashCode()Returns a hash code computed from each object's hash code.- Specified by:
hashCodein interfaceCollection<E>- Specified by:
hashCodein interfaceList<E>- Overrides:
hashCodein classAbstractEList<E>- Returns:
- a hash code.
-
delegateHashCode
protected int delegateHashCode()Returns the hash code of the backing store list.- Returns:
- a hash code.
-
toString
Returns a string of the form"[object1, object2]".- Overrides:
toStringin classAbstractEList<E>- Returns:
- a string of the form
"[object1, object2]".
-
delegateToString
Returns a the string form of the backing store list.- Returns:
- a the string form of the backing store list.
-
delegateIterator
Returns an iterator over the backing store list.- Returns:
- an iterator.
-
delegateListIterator
Returns a list iterator over the backing store list.- Returns:
- a list iterator.
-
basicList
Returns an unsafe list that provides anon-resolvingview of the backing store list.- Specified by:
basicListin classAbstractEList<E>- Returns:
- an unsafe list that provides a non-resolving view of the backing store list.
-
delegateBasicList
Returns an unsafe list that provides anon-resolvingview of the backing store list.- Returns:
- an unsafe list that provides a non-resolving view of the backing store list.
-