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 Linkprivate static Element
getEndElement(InstanceSpecification link, java.util.function.Function<Association,Property> memberGetter)
static 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 typesprivate static boolean
isClassifierSameAsType(InstanceSpecification link, Property memberEnd)
Checks if Slot Instance Value's classifier is the same as property's typestatic 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 changedprivate static void
moveSlotValues(Property stableEnd, InstanceSpecification source, InstanceSpecification destination, InstanceSpecification stableInstance)
moves slot values from source element and moves them to the destination elementstatic void
setConnectedInstance(InstanceSpecification link, Element value, Property memberEnd)
static void
setLinkClientElement(InstanceSpecification link, Element value)
Sets client element from InstanceSpecification (link)private static void
setLinkEndElement(InstanceSpecification link, Element value, Element disconnectedElement, Element stableElement, java.util.function.Function<Association,Property> movedEndGetter, java.util.function.Function<Association,Property> stableEndGetter)
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 switchedprivate static void
updateStableElement(Property movedEnd, InstanceSpecification source, InstanceSpecification destination, InstanceSpecification stableInstance)
-
-
-
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
-
getEndElement
@CheckForNull private static Element getEndElement(InstanceSpecification link, java.util.function.Function<Association,Property> memberGetter)
-
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
-
isClassifierSameAsType
private static boolean isClassifierSameAsType(InstanceSpecification link, Property memberEnd)
Checks if Slot Instance Value's classifier is the same as property's type- Parameters:
link
- analyzed linkmemberEnd
- analyzed link/association end- Returns:
- true if value classifier matches property type
-
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)
-
moveSlotValues
private static void moveSlotValues(Property stableEnd, InstanceSpecification source, InstanceSpecification destination, InstanceSpecification stableInstance)
moves slot values from source element and moves them to the destination element- Parameters:
stableEnd
- property for stable endsource
- disconnected instancedestination
- connected instancestableInstance
- stable instance (which end was not changed)
-
updateStableElement
private static void updateStableElement(Property movedEnd, InstanceSpecification source, InstanceSpecification destination, InstanceSpecification stableInstance)
-
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
-
setLinkEndElement
private static void setLinkEndElement(InstanceSpecification link, Element value, @CheckForNull Element disconnectedElement, @CheckForNull Element stableElement, java.util.function.Function<Association,Property> movedEndGetter, java.util.function.Function<Association,Property> stableEndGetter)
-
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
-
-