Class QVToModelCache
- java.lang.Object
-
- org.palladiosimulator.simulizar.reconfiguration.qvto.util.QVToModelCache
-
-
Constructor Summary
Constructors Constructor Description QVToModelCache(IModelAccess modelAccess)
Initializes a new instance of theQVToModelCache
class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears the cache, that is, all models are removed.boolean
containsModelOfType(EPackage ePackage)
Gets whether a model of the meta-model represented by the given ePackage is currently in store.Collection<EObject>
getModelsByType(EPackage ePackage)
Gets the currently stored model that is an instance of the meta-model represented by the given ePackage.void
removeModel(EObject model)
Removes the given model from the cache, if present.
This method does nothing, ifnull
is passed or the given model is not cached.void
removeModelOfType(EPackage metaModel)
Removes all of the currently stored models which are instances of the meta-model represented by the given ePackage.
In casenull
is passed, this method does nothing.QVToModelCache
snapshot()
Creates a snapshot of the current state of the cache.
More precisely, this method creates an instance that contains the same models as this one.void
storeModel(EObject modelInstance)
Stores the given model in the cache.void
storeModelFromBlackboardPartition(String partitionId)
Stores the model found in the partition of the blackboard that is identified by the given id.
-
-
-
Constructor Detail
-
QVToModelCache
public QVToModelCache(IModelAccess modelAccess)
Initializes a new instance of theQVToModelCache
class.- Parameters:
modelAccess
- AnIModelAccess
implementation that is used to access the globally available models such as the PCM models.- Throws:
NullPointerException
- In casemodelAccess == null
.- See Also:
IModelAccess.getBlackboard()
,IModelAccess.getGlobalPCMModel()
-
-
Method Detail
-
storeModel
public void storeModel(EObject modelInstance)
Stores the given model in the cache. If a model of the same type (denoted by the meta-model, i.e., theEPackage
that corresponds to the model) is already present, it will be overwritten.
In casenull
is passed, this method does nothing.- Parameters:
modelInstance
- AnEObject
representing a model.
-
storeModelFromBlackboardPartition
public final void storeModelFromBlackboardPartition(String partitionId)
Stores the model found in the partition of the blackboard that is identified by the given id. If a model of the same type (denoted by the meta-model, i.e., theEPackage
that corresponds to the model) is already present, it will be overwritten.
If the given id does not identify a partition, or the requested partition is empty, nothing happens.- Parameters:
partitionId
- A String which identifies aResourceSetPartition
of the the globalMDSDBlackboard
.- Throws:
NullPointerException
- In casepartitionId == null
.- See Also:
storeModel(EObject)
-
removeModelOfType
public void removeModelOfType(EPackage metaModel)
Removes all of the currently stored models which are instances of the meta-model represented by the given ePackage.
In casenull
is passed, this method does nothing.- Parameters:
ePackage
- AnEPackage
that describes a meta-model.
-
removeModel
public void removeModel(EObject model)
Removes the given model from the cache, if present.
This method does nothing, ifnull
is passed or the given model is not cached.- Parameters:
model
- TheEObject
to remove from the cache.
-
clear
public void clear()
Clears the cache, that is, all models are removed.
-
snapshot
public QVToModelCache snapshot()
Creates a snapshot of the current state of the cache.
More precisely, this method creates an instance that contains the same models as this one.- Returns:
- A
QVToModelCache
which is a snapshot of the current state of this instance.
-
getModelsByType
public Collection<EObject> getModelsByType(EPackage ePackage)
Gets the currently stored model that is an instance of the meta-model represented by the given ePackage.- Parameters:
ePackage
- AnEPackage
that describes a meta-model.- Returns:
- The model, contained in an
Optional
and represented as anEObject
, that is an instance of the given meta-model, or an emptyOptional
if none could be found. - Throws:
NullPointerException
- In caseePackage == null
.
-
containsModelOfType
public boolean containsModelOfType(EPackage ePackage)
Gets whether a model of the meta-model represented by the given ePackage is currently in store.- Parameters:
ePackage
- AnEPackage
that describes a meta-model.- Returns:
true
if a model of the given type is stored,false
otherwise.- Throws:
NullPointerException
- In caseePackage == null
.- See Also:
getModelsByType(EPackage)
-
-