public abstract class AbstractKFList<T> extends Object implements Collection<T>, FeatureStateListener
Collection
with multi-context support.
This class can only be embedded in Kernel code. It cannot be embedded into Feature code.
This collection does not allow to pass null
elements.
The semantic is the following:
ArrayList
.Collection.clear()
method clears the whole collection. The
call to Collection.iterator()
method return an iterator on all objects of the collection...Constructor and Description |
---|
AbstractKFList() |
Modifier and Type | Method and Description |
---|---|
boolean |
addAll(Collection<? extends T> c)
Adds all of the elements in the specified collection to this collection (optional operation).
|
boolean |
containsAll(Collection<?> c)
Returns
true if this collection contains all of the elements in the specified
collection. |
boolean |
removeAll(Collection<?> c)
Removes all of this collection's elements that are also contained in the specified collection
(optional operation).
|
protected abstract void |
removeAllElementsOwnedBy(Feature feature)
Removed all elements owned by the given
Feature . |
boolean |
retainAll(Collection<?> c)
Retains only the elements in this collection that are contained in the specified collection
(optional operation).
|
void |
stateChanged(Feature feature,
Feature.State previousState)
Called when the state of a Feature has changed.
|
Object[] |
toArray()
Returns an array containing all of the elements in this collection.
|
protected abstract void |
toArray(ArrayList<T> allList)
Add all the elements of the collection to the given
ArrayList . |
<E> E[] |
toArray(E[] a)
Returns an array containing all of the elements in this collection; the runtime type of the
returned array is that of the specified array.
|
public boolean addAll(Collection<? extends T> c)
Collection
addAll
in interface Collection<T>
c
- collection containing elements to be added to this collectiontrue
if this collection changed as a result of the callCollection.add(Object)
public boolean containsAll(Collection<?> c)
Collection
true
if this collection contains all of the elements in the specified
collection.containsAll
in interface Collection<T>
c
- collection to be checked for containment in this collectiontrue
if this collection contains all of the elements in the specified collectionCollection.contains(Object)
public boolean removeAll(Collection<?> c)
Collection
removeAll
in interface Collection<T>
c
- collection containing elements to be removed from this collectiontrue
if this collection changed as a result of the callCollection.remove(Object)
,
Collection.contains(Object)
protected abstract void removeAllElementsOwnedBy(Feature feature)
Feature
.feature
- the owner of the elements to be removedpublic boolean retainAll(Collection<?> c)
Collection
retainAll
in interface Collection<T>
c
- collection containing elements to be retained in this collectiontrue
if this collection changed as a result of the callCollection.remove(Object)
,
Collection.contains(Object)
public final void stateChanged(Feature feature, Feature.State previousState)
FeatureStateListener
stateChanged
in interface FeatureStateListener
feature
- the Feature which state has changedpreviousState
- the previous state, null
if Feature state is Feature.State.INSTALLED
public Object[] toArray()
Collection
The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.
This method acts as bridge between array-based and collection-based APIs.
toArray
in interface Collection<T>
protected abstract void toArray(ArrayList<T> allList)
ArrayList
.allList
- the list where all elements are added.public <E> E[] toArray(E[] a)
Collection
If this collection fits in the specified array with room to spare (i.e., the array has more
elements than this collection), the element in the array immediately following the end of the
collection is set to null
. (This is useful in determining the length of this collection
only if the caller knows that this collection does not contain any null
elements.)
If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
Like the Collection.toArray()
method, this method acts as bridge between array-based and
collection-based APIs. Further, this method allows precise control over the runtime type of the
output array, and may, under certain circumstances, be used to save allocation costs.
Suppose x
is a collection known to contain only strings. The following code can be used
to dump the collection into a newly allocated array of String
:
String[] y = x.toArray(new String[0]);Note that
toArray(new Object[0])
is identical in function to toArray()
.toArray
in interface Collection<T>
E
- the runtime type of the array to contain the collectiona
- the array into which the elements of this collection are to be stored, if it is big
enough; otherwise, a new array of the same runtime type is allocated for this purpose.