Class AbstractKFList<T>
- java.lang.Object
-
- com.microej.kf.util.AbstractKFList<T>
-
- All Implemented Interfaces:
FeatureStateListener,Iterable<T>,Collection<T>
public abstract class AbstractKFList<T> extends Object implements Collection<T>, FeatureStateListener
Implementation of aCollectionwith 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
nullelements.The semantic is the following:
- Each context has its dedicated list, acting as an
ArrayList. - A Feature can add Feature or Kernel objects to its list.
- The Kernel can only add Kernel objects to its list. However it has the full control and visibility on all the
elements of the collection. For example, the call of the
Collection.clear()method clears the whole collection. The call toCollection.iterator()method return an iterator on all objects of the collection...
-
-
Constructor Summary
Constructors Constructor Description AbstractKFList()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanaddAll(Collection<? extends T> c)Adds all of the elements in the specified collection to this collection (optional operation).booleancontainsAll(Collection<?> c)Returnstrueif this collection contains all of the elements in the specified collection.booleanremoveAll(Collection<?> c)Removes all of this collection's elements that are also contained in the specified collection (optional operation).protected abstract voidremoveAllElementsOwnedBy(Feature feature)Removed all elements owned by the givenFeature.booleanretainAll(Collection<?> c)Retains only the elements in this collection that are contained in the specified collection (optional operation).voidstateChanged(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.<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.protected abstract voidtoArray(ArrayList<T> allList)Add all the elements of the collection to the givenArrayList.
-
-
-
Method Detail
-
stateChanged
public final void stateChanged(Feature feature, Feature.State previousState)
Description copied from interface:FeatureStateListenerCalled when the state of a Feature has changed.- Specified by:
stateChangedin interfaceFeatureStateListener- Parameters:
feature- the Feature which state has changedpreviousState- the previous state,nullif Feature state isFeature.State.INSTALLED
-
addAll
public boolean addAll(Collection<? extends T> c)
Description copied from interface:CollectionAdds all of the elements in the specified collection to this collection (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty.)- Specified by:
addAllin interfaceCollection<T>- Parameters:
c- collection containing elements to be added to this collection- Returns:
trueif this collection changed as a result of the call- See Also:
Collection.add(Object)
-
containsAll
public boolean containsAll(Collection<?> c)
Description copied from interface:CollectionReturnstrueif this collection contains all of the elements in the specified collection.- Specified by:
containsAllin interfaceCollection<T>- Parameters:
c- collection to be checked for containment in this collection- Returns:
trueif this collection contains all of the elements in the specified collection- See Also:
Collection.contains(Object)
-
removeAll
public boolean removeAll(Collection<?> c)
Description copied from interface:CollectionRemoves all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.- Specified by:
removeAllin interfaceCollection<T>- Parameters:
c- collection containing elements to be removed from this collection- Returns:
trueif this collection changed as a result of the call- See Also:
Collection.remove(Object),Collection.contains(Object)
-
retainAll
public boolean retainAll(Collection<?> c)
Description copied from interface:CollectionRetains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.- Specified by:
retainAllin interfaceCollection<T>- Parameters:
c- collection containing elements to be retained in this collection- Returns:
trueif this collection changed as a result of the call- See Also:
Collection.remove(Object),Collection.contains(Object)
-
toArray
public Object[] toArray()
Description copied from interface:CollectionReturns an array containing all of the elements in this collection. 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.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.
- Specified by:
toArrayin interfaceCollection<T>- Returns:
- an array containing all of the elements in this collection
-
toArray
public <E> E[] toArray(E[] a)
Description copied from interface:CollectionReturns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this 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 anynullelements.)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
xis a collection known to contain only strings. The following code can be used to dump the collection into a newly allocated array ofString:String[] y = x.toArray(new String[0]);
Note thattoArray(new Object[0])is identical in function totoArray().- Specified by:
toArrayin interfaceCollection<T>- Type Parameters:
E- the runtime type of the array to contain the collection- Parameters:
a- 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.- Returns:
- an array containing all of the elements in this collection
-
removeAllElementsOwnedBy
protected abstract void removeAllElementsOwnedBy(Feature feature)
Removed all elements owned by the givenFeature.- Parameters:
feature- the owner of the elements to be removed
-
-