Class EntityReference<EntityType extends org.palladiosimulator.pcm.core.entity.Entity>
- java.lang.Object
-
- org.palladiosimulator.simulizar.entity.EntityReference<EntityType>
-
- Type Parameters:
EntityType
- the type of the referenced model entity.
- Direct Known Subclasses:
LinkingResourceReference
,ResourceContainerReference
,UsageScenarioReference
public class EntityReference<EntityType extends org.palladiosimulator.pcm.core.entity.Entity> extends Object
The entity reference class serves as a type safe model element pointer. As the blackboard partitions reflect the current state of the global model at the point in time when the interpretation started, there can be several model element instances pointing to the same entity. Storing model elements directly can lead to memory leaks, as older resource sets which are not referenced by interpreters anymore are not properly cleaned up. The entity model reference allows to access the model element directly given aPCMResourceSetPartition
. It encapsulates the required lookup logic. Once a lookup is done, the model element is cached, but may be cleaned up by the garbage collector. Using an entity reference has the advantage of giving some semantics and type-safety to aIdentifier.getId()
. It can be stored, and checked for equality usingObject.equals(Object)
andObject.hashCode()
. NOTE: In order to provide a more efficient model element lookup mechanism a specialized implementation can be provided. The default behavior is to check the ID of every single Entity in the provided partition until a suitable match is found.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EntityReference.AbstractEntityReferenceFactory<EntityType extends org.palladiosimulator.pcm.core.entity.Entity>
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
String
getId()
EntityType
getModelElement(org.palladiosimulator.analyzer.workflow.blackboard.PCMResourceSetPartition partition)
Gets the model element of the referenced entity from the given resource set partition.Optional<EntityType>
getModelElementIfPresent(org.palladiosimulator.analyzer.workflow.blackboard.PCMResourceSetPartition partition)
Gets the model element of the referenced entity from the given resource set partition.int
hashCode()
protected Iterator<EntityType>
retrieveModelElements(org.palladiosimulator.analyzer.workflow.blackboard.PCMResourceSetPartition partition)
-
-
-
Method Detail
-
getModelElement
public EntityType getModelElement(org.palladiosimulator.analyzer.workflow.blackboard.PCMResourceSetPartition partition)
Gets the model element of the referenced entity from the given resource set partition.
-
getModelElementIfPresent
public Optional<EntityType> getModelElementIfPresent(org.palladiosimulator.analyzer.workflow.blackboard.PCMResourceSetPartition partition)
Gets the model element of the referenced entity from the given resource set partition.
-
getId
public String getId()
-
retrieveModelElements
protected Iterator<EntityType> retrieveModelElements(org.palladiosimulator.analyzer.workflow.blackboard.PCMResourceSetPartition partition)
-
-