org.eclipse.emf.emfstore.internal.common.model
Interface IdEObjectCollection

All Superinterfaces:
APIDelegate<ESModelElementIdToEObjectMappingImpl>, org.eclipse.emf.ecore.EObject, ESIdToEObjectMapping<ModelElementId>, ESObjectContainer<ModelElementId>, ModelElementIdToEObjectMapping, org.eclipse.emf.common.notify.Notifier
All Known Subinterfaces:
NotifiableIdEObjectCollection, Project
All Known Implementing Classes:
IdEObjectCollectionImpl, NotifiableIdEObjectCollectionImpl, ProjectImpl

public interface IdEObjectCollection
extends org.eclipse.emf.ecore.EObject, ESObjectContainer<ModelElementId>, ModelElementIdToEObjectMapping

A collection of EObjects where each one can be identified via a ModelElementId. EObjects can be added and deleted and checked whether they are part of the collection.

Author:
emueller

Method Summary
 void addModelElement(org.eclipse.emf.ecore.EObject modelElement)
          Adds the given model element to the collection.
 void allocateModelElementIds(Map<org.eclipse.emf.ecore.EObject,ModelElementId> modelElementToIdMap)
          Allocates certain IDs for the given model elements in the mapping.
 void clearAllocatedCaches()
          Clear allocated caches.
 boolean contains(org.eclipse.emf.ecore.EObject modelElement)
          Checks whether a given EObject is contained in the collection.
 boolean contains(ModelElementId eObjectId)
          Checks whether the EObject with the given ESModelElementId is contained in the collection.
 void deleteModelElement(org.eclipse.emf.ecore.EObject modelElement)
          Deletes the given model element from the collection.
 void disallocateModelElementIds(Set<ModelElementId> modelElementIds)
          Removes any allocated ID entries from this collection that are contained in the given set of ModelElementIds.
 Set<org.eclipse.emf.ecore.EObject> getAllModelElements()
           Returns a flat representation of all model elements in the collection.
 Map<org.eclipse.emf.ecore.EObject,String> getEObjectToIdMapping()
          Returns a copy of the EObject/ID mapping where IDs are represented as strings.
 Map<String,org.eclipse.emf.ecore.EObject> getIdToEObjectMapping()
          Returns a copy of the ID/EObject mapping where IDs are represented as strings.
 org.eclipse.emf.ecore.EObject getModelElement(ModelElementId modelElementId)
          Returns the model element with the given ESModelElementId.
 ModelElementId getModelElementId(org.eclipse.emf.ecore.EObject modelElement)
          Retrieve the ESModelElementId of the given model element.
 org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> getModelElements()
          Returns all directly contained model element of the container, i.e.
<T extends org.eclipse.emf.ecore.EObject>
org.eclipse.emf.common.util.EList<T>
getModelElementsByClass(org.eclipse.emf.ecore.EClass modelElementClass, org.eclipse.emf.common.util.EList<T> list)
          Retrieve a list of model elements of a certain type in the collection that are directly contained in the collection.
 void initMapping()
          Initializes the ID caches of the collection, i.e.
 void initMapping(Map<org.eclipse.emf.ecore.EObject,String> eObjectToIdMap, Map<String,org.eclipse.emf.ecore.EObject> idToEObjectMap)
          /** Initializes the ID caches of the project with the given mappings.
 
Methods inherited from interface org.eclipse.emf.ecore.EObject
eAllContents, eClass, eContainer, eContainingFeature, eContainmentFeature, eContents, eCrossReferences, eGet, eGet, eInvoke, eIsProxy, eIsSet, eResource, eSet, eUnset
 
Methods inherited from interface org.eclipse.emf.common.notify.Notifier
eAdapters, eDeliver, eNotify, eSetDeliver
 
Methods inherited from interface org.eclipse.emf.emfstore.common.model.ESObjectContainer
getAllModelElementsByClass, getAllModelElementsByClass
 
Methods inherited from interface org.eclipse.emf.emfstore.common.model.ESIdToEObjectMapping
get
 
Methods inherited from interface org.eclipse.emf.emfstore.internal.common.api.APIDelegate
createAPI, toAPI
 

Method Detail

addModelElement

void addModelElement(org.eclipse.emf.ecore.EObject modelElement)
Adds the given model element to the collection.

Parameters:
modelElement - the model element that should be added to the collection

clearAllocatedCaches

void clearAllocatedCaches()
Clear allocated caches.


allocateModelElementIds

void allocateModelElementIds(Map<org.eclipse.emf.ecore.EObject,ModelElementId> modelElementToIdMap)
Allocates certain IDs for the given model elements in the mapping. If any EObject contained in the mapping is added to this collection its ModelElementId will be determined using the ID in the mapping.

Parameters:
modelElementToIdMap - A map containing ModelElementIds for the model element and its children

disallocateModelElementIds

void disallocateModelElementIds(Set<ModelElementId> modelElementIds)
Removes any allocated ID entries from this collection that are contained in the given set of ModelElementIds.

Parameters:
modelElementIds - the set of model element IDs to be released

contains

boolean contains(org.eclipse.emf.ecore.EObject modelElement)
Checks whether a given EObject is contained in the collection.

Specified by:
contains in interface ESObjectContainer<ModelElementId>
Parameters:
modelElement - the model element to be checked, whether it is contained in the collection
Returns:
true, if the model element is contained in the collection, false otherwise
See Also:
ESObjectContainer.contains(org.eclipse.emf.ecore.EObject)

contains

boolean contains(ModelElementId eObjectId)
Checks whether the EObject with the given ESModelElementId is contained in the collection.

Specified by:
contains in interface ESObjectContainer<ModelElementId>
Parameters:
eObjectId - the model element ID of the EObject, which needs to be checked, whether it is contained in the collection
Returns:
true, if the EObject with the given model element ID is contained in the collection, false
See Also:
ESObjectContainer.contains(java.lang.Object)

getModelElementId

ModelElementId getModelElementId(org.eclipse.emf.ecore.EObject modelElement)
Retrieve the ESModelElementId of the given model element.

Specified by:
getModelElementId in interface ESObjectContainer<ModelElementId>
Parameters:
modelElement - the model element for which to retrieve the ID for
Returns:
the ESModelElementId of the given model element
See Also:
ESObjectContainer.getModelElementId(org.eclipse.emf.ecore.EObject)

getModelElement

org.eclipse.emf.ecore.EObject getModelElement(ModelElementId modelElementId)
Returns the model element with the given ESModelElementId.

Specified by:
getModelElement in interface ESObjectContainer<ModelElementId>
Parameters:
modelElementId - the ID of the model element, that should be retrieved
Returns:
the model element that has the given ID assigned to it within the container
See Also:
ESObjectContainer.getModelElement(java.lang.Object)

getModelElements

org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> getModelElements()
Returns all directly contained model element of the container, i.e. a hierarchical representation of the model elements.

Specified by:
getModelElements in interface ESObjectContainer<ModelElementId>
Returns:
a list containing the directly contained model elements within the container
See Also:
ESObjectContainer.getModelElements()

deleteModelElement

void deleteModelElement(org.eclipse.emf.ecore.EObject modelElement)
Deletes the given model element from the collection.

Parameters:
modelElement - the model element that should get deleted

getAllModelElements

Set<org.eclipse.emf.ecore.EObject> getAllModelElements()

Returns a flat representation of all model elements in the collection.

The returned set is not modifiable and will throw an UnsupportedOperationException in case trying to do so.

Specified by:
getAllModelElements in interface ESObjectContainer<ModelElementId>
Returns:
a set of all model elements contained in the collection
See Also:
ESObjectContainer.getAllModelElements()

getModelElementsByClass

<T extends org.eclipse.emf.ecore.EObject> org.eclipse.emf.common.util.EList<T> getModelElementsByClass(org.eclipse.emf.ecore.EClass modelElementClass,
                                                                                                       org.eclipse.emf.common.util.EList<T> list)
Retrieve a list of model elements of a certain type in the collection that are directly contained in the collection.

Type Parameters:
T - a sub-type of model element
Parameters:
modelElementClass - the EClass
list - a list of model elements, can be empty, but must be of the same type as the modelElementClass indicates.
Returns:
a list of model elements of the given type

initMapping

void initMapping(Map<org.eclipse.emf.ecore.EObject,String> eObjectToIdMap,
                 Map<String,org.eclipse.emf.ecore.EObject> idToEObjectMap)
/** Initializes the ID caches of the project with the given mappings.

Parameters:
eObjectToIdMap - a mapping from EObjects to IDs
idToEObjectMap - the reverse mapping of eObjectToIdMap

initMapping

void initMapping()
Initializes the ID caches of the collection, i.e. the collection will call getModelElements() and for each model element the ModelElementId is fetched via getModelElementId(EObject). Then a mapping between the model element and its ModelElementId is created within the cache.


getIdToEObjectMapping

Map<String,org.eclipse.emf.ecore.EObject> getIdToEObjectMapping()
Returns a copy of the ID/EObject mapping where IDs are represented as strings. This method is mainly provided for convenience and performance reasons, where the ID must be a string.

Returns:
the ID/EObject mapping

getEObjectToIdMapping

Map<org.eclipse.emf.ecore.EObject,String> getEObjectToIdMapping()
Returns a copy of the EObject/ID mapping where IDs are represented as strings. This method is mainly provided for convenience and performance reasons, where the ID must be a string.

Returns:
the EObject/ID mapping


Copyright © 2015. All Rights Reserved.