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.
- All Implemented Interfaces:
InterpretableLocationReference
- Direct Known Subclasses:
LinkingResourceReference
,ResourceContainerReference
,UsageScenarioReference
public class EntityReference<EntityType extends org.palladiosimulator.pcm.core.entity.Entity> extends Object implements InterpretableLocationReference
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()
String
getLocationIdentifier()
Provides an identifier, which is derived based on all of the representing entities.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()
boolean
isLocationIdentifiedBy(EntityReference<?>... entityReferences)
Checks whether the referenced location is represented by the union of the provided references.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)
-
isLocationIdentifiedBy
public boolean isLocationIdentifiedBy(EntityReference<?>... entityReferences)
Description copied from interface:InterpretableLocationReference
Checks whether the referenced location is represented by the union of the provided references.- Specified by:
isLocationIdentifiedBy
in interfaceInterpretableLocationReference
- Returns:
- true, if the location is the same
-
getLocationIdentifier
public String getLocationIdentifier()
Description copied from interface:InterpretableLocationReference
Provides an identifier, which is derived based on all of the representing entities. The identifier can be used as a lookup key for storing related elements is hash map like data structs.- Specified by:
getLocationIdentifier
in interfaceInterpretableLocationReference
- Returns:
- a stable identifier, uniquely determined based on the representing elements.
-
-