Class EntityReference<EntityType extends org.palladiosimulator.pcm.core.entity.Entity>

  • 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 a PCMResourceSetPartition. 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 a Identifier.getId(). It can be stored, and checked for equality using Object.equals(Object) and Object.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.
    • 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)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object