Class Links


  • public class Links
    extends java.lang.Object
    Convenient static methods to work with Link (InstanceSpecification) elements.
    • Constructor Detail

      • Links

        public Links()
    • Method Detail

      • getClientElement

        @CheckForNull
        public static Element getClientElement​(InstanceSpecification link)
        Return client element from InstanceSpecification (link) Custom way to get relationship info from Link
        Parameters:
        link - link
        Returns:
        Client element
      • getSupplierElement

        @CheckForNull
        public static Element getSupplierElement​(InstanceSpecification link)
        Returns supplier element from InstanceSpecification (Link)
        Parameters:
        link - link
        Returns:
        supplier element
      • synchronizeLinkSlotValuesByType

        public static void synchronizeLinkSlotValuesByType​(InstanceSpecification link)
        During link end change, sometimes opposite side instance values are defined, and they need to be switched
        Parameters:
        link - synchronized link
      • hasCorrectClassifier

        public static java.util.Collection<Classifier> hasCorrectClassifier​(InstanceSpecification link)
        Checks if link is connected to instances according to its association; Check is done by checking if instance values has classifiers same as association member end types
        Parameters:
        link - link (only links are analyzed)
        Returns:
        empty list if OK, wrong classifiers if not
      • moveSlotReference

        public static void moveSlotReference​(Property stableEnd,
                                             Property movedEnd,
                                             InstanceSpecification source,
                                             InstanceSpecification destination,
                                             InstanceSpecification stableInstance)
        Updates slots when link ends were changed
        Parameters:
        stableEnd - association member end, which is representing link end does not move
        movedEnd - association member end, which is representing link end moves
        source - disconnected instance
        destination - connected instance
        stableInstance - stable instance (which end was not changed)
      • setLinkClientElement

        public static void setLinkClientElement​(InstanceSpecification link,
                                                Element value)
        Sets client element from InstanceSpecification (link)
        Parameters:
        link - link
        value - new client value
      • setLinkSupplierElement

        public static void setLinkSupplierElement​(InstanceSpecification link,
                                                  Element value)
        Sets supplier element for InstanceSpecification (link) Custom way to make Link behavior as relationship - add client and supplier info to the slots
        Parameters:
        link - link
        value - new supplier value
      • isLink

        public static boolean isLink​(@CheckForNull
                                     InstanceSpecification instance)
        Checks if InstanceSpecification is Link.
        Parameters:
        instance - instance to check
        Returns:
        true if it is Link element - it has Association as classifier or has a Link symbol in diagram
      • getAssociationsOfLink

        public static java.util.Collection<Association> getAssociationsOfLink​(InstanceSpecification instance)
        Gets Association classifier from InstanceSpecification, if exists.
        Parameters:
        instance - Link instance
        Returns:
        Associations or empty collection
      • findRelatedLinks

        public static java.util.Collection<InstanceSpecification> findRelatedLinks​(@CheckForNull
                                                                                   Slot slot)
        If slot value corresponds to connected instance, returns link which connects two instances.
        Parameters:
        slot - instance slot
        Returns:
        connecting links
      • findRelatedLinks

        public static java.util.Collection<InstanceSpecification> findRelatedLinks​(@CheckForNull
                                                                                   InstanceValue instanceValue)
        If Instance value corresponds to connected instance, returns link which connects two instances.
        Parameters:
        instanceValue - instance value
        Returns:
        connecting links
      • findRelatedAssociation

        @CheckForNull
        public static Association findRelatedAssociation​(@CheckForNull
                                                         ValueSpecification value)
        If owning slot defining feature is association member end - returns that association
        Parameters:
        value - slot instance value
        Returns:
        association which property is defining feature for instance value owning slot or null
      • findRelatedAssociation

        @CheckForNull
        public static Association findRelatedAssociation​(@CheckForNull
                                                         Slot slot)
        Association property of Slot defining feature
        Parameters:
        slot - slot
        Returns:
        Association of defining feature or null