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

  • 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 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
      • 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 interface InterpretableLocationReference
        Returns:
        a stable identifier, uniquely determined based on the representing elements.