Package com.nomagic.magicdraw.uml2
Class Links
- java.lang.Object
-
- com.nomagic.magicdraw.uml2.Links
-
public class Links extends java.lang.Object
Convenient static methods to work with Link (InstanceSpecification) elements.
-
-
Constructor Summary
Constructors Constructor Description Links()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Association
findRelatedAssociation(Slot slot)
Association property of Slot defining featurestatic Association
findRelatedAssociation(ValueSpecification value)
If owning slot defining feature is association member end - returns that associationstatic java.util.Collection<InstanceSpecification>
findRelatedLinks(InstanceValue instanceValue)
If Instance value corresponds to connected instance, returns link which connects two instances.static java.util.Collection<InstanceSpecification>
findRelatedLinks(Slot slot)
If slot value corresponds to connected instance, returns link which connects two instances.static java.util.Collection<Association>
getAssociationsOfLink(InstanceSpecification instance)
Gets Association classifier from InstanceSpecification, if exists.static Element
getClientElement(InstanceSpecification link)
Return client element from InstanceSpecification (link) Custom way to get relationship info from Linkstatic Element
getSupplierElement(InstanceSpecification link)
Returns supplier element from InstanceSpecification (Link)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 typesstatic boolean
isLink(InstanceSpecification instance)
Checks if InstanceSpecification is Link.static void
moveSlotReference(Property stableEnd, Property movedEnd, InstanceSpecification source, InstanceSpecification destination, InstanceSpecification stableInstance)
Updates slots when link ends were changedstatic void
setConnectedInstance(InstanceSpecification link, Element value, Property memberEnd)
static void
setLinkClientElement(InstanceSpecification link, Element value)
Sets client element from InstanceSpecification (link)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 slotsstatic void
synchronizeLinkSlotValuesByType(InstanceSpecification link)
During link end change, sometimes opposite side instance values are defined, and they need to be switched
-
-
-
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
-
setConnectedInstance
public static void setConnectedInstance(InstanceSpecification link, Element value, Property memberEnd)
-
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 movemovedEnd
- association member end, which is representing link end movessource
- disconnected instancedestination
- connected instancestableInstance
- stable instance (which end was not changed)
-
setLinkClientElement
public static void setLinkClientElement(InstanceSpecification link, Element value)
Sets client element from InstanceSpecification (link)- Parameters:
link
- linkvalue
- 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
- linkvalue
- 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
-
-