Package com.nomagic.magicdraw.uml2
Class Profiles
java.lang.Object
com.nomagic.magicdraw.uml2.Profiles
Convenience static methods to work with Stereotyped elements and tagged values. Common for Stereotypes from any Profile.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Adds tagged values.static void
addValue
(Element element, Stereotype stereotype, Property tag, Object value) Adds tagged values.static void
addValue
(Element element, Stereotype stereotype, Property tag, Object value, boolean setOppositeEnd) Adds tagged values.static void
applyStereotype
(Element element, Stereotype stereotype) Extends given element with the stereotype.static void
clearValue
(Element element, Property tag) Clears value of tagged value and disposes the tagged valuestatic void
clearValue
(Element element, Property tag, boolean disposeTaggedValue) Clears value of tagged value and disposes the tagged valuestatic void
clearValue
(TaggedValue taggedValue, boolean disposeTaggedValue) Clear value of given tagged valuestatic void
createDefaultValue
(TaggedValue taggedValue, boolean createAll) Creates default values for given tagged value.static void
createDefaultValues
(Element element, Stereotype stereotype, boolean createAll) Creates tagged values with default values for tags of the given stereotype.static Stereotype
getAppliedIncludingDerived
(Element element, Stereotype stereotype) Checks if the given stereotype or it's subtype stereotype is already applied to the element, and returns the applied stereotypestatic Collection<Stereotype>
getAppliedStereotypes
(Collection<? extends Element> elements) Returns a set of all applied stereotypes for any of the elements in the collectionstatic ExtensionEnd
getExtensionEnd
(Extension extension) ExtensionEnd of given Extensionstatic Stereotype
getFirstApplied
(Element element, Collection<? extends Stereotype> stereotypes) Checks if there is at least one stereotype is already applied to the element, and returns the first found stereotype.static Stereotype
getFirstAppliedIncludingDerived
(Element element, Collection<? extends Stereotype> stereotypes) Checks if there is at least one stereotype or stereotype derived from it already applied to the element, and returns the first found stereotypestatic Object
getFirstValue
(Element element, Property tag) static Collection<Element>
getStereotypedElements
(Stereotype stereotype) Returns all elements stereotyped by stereotypestatic Collection<Element>
getStereotypedElementsIncludingDerived
(Stereotype stereotype) Returns all elements stereotyped by stereotype and by stereotypes derived from this stereotype.static TaggedValue
getTaggedValue
(Element element, Property tag) Return tagged value for given tag definition.static List<?>
Gets the value of the stereotype property (a.k.a tag) as list.static boolean
isStereotypeApplied
(Element element, Stereotype stereotype) Checks if element has the given stereotype appliedstatic void
Sets tagged values.static void
setValue
(Element element, Stereotype stereotype, Property tag, Object value) Sets tagged values.static void
setValue
(Element element, Stereotype stereotype, Property tag, Object value, boolean setOppositeEnd) Sets tagged values.static void
setValue
(TaggedValue taggedValue, Object value) Sets tagged values.static void
setValue
(TaggedValue taggedValue, Object value, boolean setOppositeEnd) Sets tagged values.static void
unapplyStereotype
(Element element, Stereotype stereotype) Remove stereotype from element, if it is applied.
-
Constructor Details
-
Profiles
public Profiles()
-
-
Method Details
-
getStereotypedElements
Returns all elements stereotyped by stereotype- Parameters:
stereotype
- stereotype- Returns:
- list of elements stereotyped by stereotype
-
getStereotypedElementsIncludingDerived
Returns all elements stereotyped by stereotype and by stereotypes derived from this stereotype.- Parameters:
stereotype
- stereotype- Returns:
- collection of elements stereotyped by stereotype or derived ones
-
getAppliedIncludingDerived
@CheckForNull public static Stereotype getAppliedIncludingDerived(Element element, Stereotype stereotype) Checks if the given stereotype or it's subtype stereotype is already applied to the element, and returns the applied stereotype- Parameters:
element
- elementstereotype
- stereotype to check for- Returns:
- given stereotype or stereotype derived from it, if applied to the element
-
getAppliedStereotypes
Returns a set of all applied stereotypes for any of the elements in the collection- Parameters:
elements
- collection of elements- Returns:
- collection stereotypes, each is applied on one or more of the provided elements
-
getFirstApplied
@CheckForNull public static Stereotype getFirstApplied(Element element, Collection<? extends Stereotype> stereotypes) Checks if there is at least one stereotype is already applied to the element, and returns the first found stereotype.- Parameters:
element
- elementstereotypes
- a collection of stereotypes to check- Returns:
- one of the provided stereotypes if applied to this element
-
getFirstAppliedIncludingDerived
@CheckForNull public static Stereotype getFirstAppliedIncludingDerived(Element element, Collection<? extends Stereotype> stereotypes) Checks if there is at least one stereotype or stereotype derived from it already applied to the element, and returns the first found stereotype- Parameters:
element
- elementstereotypes
- a collection of stereotypes to check- Returns:
- one of the provided stereotypes, or stereotype derived from it, if applied to this element
-
isStereotypeApplied
Checks if element has the given stereotype applied- Parameters:
element
- element to checkstereotype
- stereotype name to check- Returns:
- true if element has applied stereotype with given name
-
applyStereotype
Extends given element with the stereotype. The default tag values are not created. The default tag values are not created, to create these values usecreateDefaultValues(Element, Stereotype, boolean)
- Parameters:
element
- elementstereotype
- stereotype to add
-
unapplyStereotype
Remove stereotype from element, if it is applied. Removes also tagged values of removed stereotype- Parameters:
element
- elementstereotype
- stereotype to remove
-
createDefaultValues
Creates tagged values with default values for tags of the given stereotype. The stereotype must be already applied to the element.- Parameters:
element
- element that has the stereotype appliedstereotype
- stereotype applied to the elementcreateAll
- provide true to creates tagged values for all tags with default value (do not check multiplicity). false, to only create tagged values for tags with mandatory value, i.e. with lower multiplicity >= 1.
-
createDefaultValue
Creates default values for given tagged value.- Parameters:
taggedValue
- tagged valuecreateAll
- provide true to creates default value (do not check multiplicity). false, to only create tagged values for tags with mandatory value, i.e. with lower multiplicity >= 1.
-
getValue
Gets the value of the stereotype property (a.k.a tag) as list.- Parameters:
element
- element with applied stereotypetag
- property owned by the applied stereotype- Returns:
- tagged values values (a modifiable copy of original values lists)
-
getFirstValue
-
getTaggedValue
Return tagged value for given tag definition.- Parameters:
element
- elementtag
- tag definition- Returns:
- tagged value
-
setValue
Sets tagged values. Existing values will be replaced.- Parameters:
element
- element with applied stereotypetag
- property owned by the stereotypevalue
- value to set, null is ignored
-
setValue
public static void setValue(Element element, @CheckForNull Stereotype stereotype, @CheckForNull Property tag, @CheckForNull Object value) Sets tagged values. Existing values will be replaced.- Parameters:
element
- element with applied stereotypestereotype
- the applied stereotypetag
- tag definitionvalue
- value to set, null is ignored
-
setValue
public static void setValue(Element element, @CheckForNull Stereotype stereotype, @CheckForNull Property tag, @CheckForNull Object value, boolean setOppositeEnd) Sets tagged values. Existing values will be replaced.- Parameters:
element
- element with applied stereotypestereotype
- the applied stereotypetag
- tag definitionvalue
- value to set, null is ignoredsetOppositeEnd
- provide true to update the value of the tag which is the opposite end of the tag's association
-
addValue
Adds tagged values.- Parameters:
element
- element with applied stereotypetag
- property owned by the stereotypevalue
- value to add, null is ignored
-
addValue
public static void addValue(Element element, @CheckForNull Stereotype stereotype, @CheckForNull Property tag, @CheckForNull Object value) Adds tagged values.- Parameters:
element
- element with applied stereotypestereotype
- the applied stereotypetag
- tag definitionvalue
- value to add, null is ignored
-
addValue
public static void addValue(Element element, @CheckForNull Stereotype stereotype, @CheckForNull Property tag, @CheckForNull Object value, boolean setOppositeEnd) Adds tagged values.- Parameters:
element
- element with applied stereotypestereotype
- the applied stereotypetag
- tag definitionvalue
- value to add, null is ignoredsetOppositeEnd
- provide true to update the value of the tag which is the opposite end of the tag's association
-
getExtensionEnd
ExtensionEnd of given Extension- Parameters:
extension
- Extension- Returns:
- ExtensionEnd of Extension
-
setValue
public static void setValue(TaggedValue taggedValue, @CheckForNull Object value, boolean setOppositeEnd) Sets tagged values. Existing values will be replaced.- Parameters:
taggedValue
- tagged valuevalue
- value to setsetOppositeEnd
- provide true to update the value of the tag which is the opposite end of the tag's association
-
setValue
Sets tagged values. Existing values will be replaced.- Parameters:
taggedValue
- tagged valuevalue
- value to set
-
clearValue
public static void clearValue(Element element, @CheckForNull Property tag, boolean disposeTaggedValue) Clears value of tagged value and disposes the tagged value- Parameters:
element
- stereotyped elementtag
- tag definitiondisposeTaggedValue
- dispose tagged value, not just clear values¬
-
clearValue
Clears value of tagged value and disposes the tagged value- Parameters:
element
- stereotyped elementtag
- tag definition
-
clearValue
Clear value of given tagged value- Parameters:
taggedValue
- tagged valuedisposeTaggedValue
- dispose tagged value, not just clear values¬
-