Package com.nomagic.magicdraw.uml2
Class Profiles
- java.lang.Object
-
- com.nomagic.magicdraw.uml2.Profiles
-
public class Profiles extends java.lang.Object
Convenience static methods to work with Stereotyped elements and tagged values. Common for Stereotypes from any Profile.
-
-
Constructor Summary
Constructors Constructor Description Profiles()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addValue(Element element, Property tag, java.lang.Object value)
Adds tagged values.static void
addValue(Element element, Stereotype stereotype, Property tag, java.lang.Object value)
Adds tagged values.static void
addValue(Element element, Stereotype stereotype, Property tag, java.lang.Object value, boolean setOppositeEnd)
Adds tagged values.private static com.nomagic.magicdraw.uml2.ProfilesInternal.AppliedStereotypes
appliedStereotypes()
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 java.util.Collection<Stereotype>
getAppliedStereotypes(java.util.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, java.util.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, java.util.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 java.lang.Object
getFirstValue(Element element, Property tag)
static java.util.Collection<Element>
getStereotypedElements(Stereotype stereotype)
Returns all elements stereotyped by stereotypestatic java.util.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 java.util.List<?>
getValue(Element element, Property tag)
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
setValue(Element element, Property tag, java.lang.Object value)
Sets tagged values.static void
setValue(Element element, Stereotype stereotype, Property tag, java.lang.Object value)
Sets tagged values.static void
setValue(Element element, Stereotype stereotype, Property tag, java.lang.Object value, boolean setOppositeEnd)
Sets tagged values.static void
setValue(TaggedValue taggedValue, java.lang.Object value)
Sets tagged values.static void
setValue(TaggedValue taggedValue, java.lang.Object value, boolean setOppositeEnd)
Sets tagged values.private static boolean
shouldCreateTaggedValue(boolean createAll, Property tag)
static void
unapplyStereotype(Element element, Stereotype stereotype)
Remove stereotype from element, if it is applied.
-
-
-
Method Detail
-
getStereotypedElements
public static java.util.Collection<Element> getStereotypedElements(@CheckForNull Stereotype stereotype)
Returns all elements stereotyped by stereotype- Parameters:
stereotype
- stereotype- Returns:
- list of elements stereotyped by stereotype
-
getStereotypedElementsIncludingDerived
public static java.util.Collection<Element> getStereotypedElementsIncludingDerived(Stereotype stereotype)
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
public static java.util.Collection<Stereotype> getAppliedStereotypes(java.util.Collection<? extends Element> elements)
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, java.util.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, java.util.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
public static boolean isStereotypeApplied(Element element, Stereotype stereotype)
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
public static void applyStereotype(Element element, @CheckForNull Stereotype stereotype)
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
public static void unapplyStereotype(Element element, @CheckForNull Stereotype stereotype)
Remove stereotype from element, if it is applied. Removes also tagged values of removed stereotype- Parameters:
element
- elementstereotype
- stereotype to remove
-
createDefaultValues
public static void createDefaultValues(Element element, Stereotype stereotype, boolean createAll)
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
public static void createDefaultValue(TaggedValue taggedValue, boolean createAll)
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.
-
shouldCreateTaggedValue
private static boolean shouldCreateTaggedValue(boolean createAll, Property tag)
-
getValue
public static java.util.List<?> getValue(Element element, @CheckForNull Property tag)
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
@CheckForNull public static java.lang.Object getFirstValue(Element element, @CheckForNull Property tag)
-
getTaggedValue
@CheckForNull public static TaggedValue getTaggedValue(Element element, @CheckForNull Property tag)
Return tagged value for given tag definition.- Parameters:
element
- elementtag
- tag definition- Returns:
- tagged value
-
setValue
public static void setValue(Element element, Property tag, @CheckForNull java.lang.Object value)
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 java.lang.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 java.lang.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
public static void addValue(Element element, Property tag, @CheckForNull java.lang.Object value)
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 java.lang.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 java.lang.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
@CheckForNull public static ExtensionEnd getExtensionEnd(Extension extension)
ExtensionEnd of given Extension- Parameters:
extension
- Extension- Returns:
- ExtensionEnd of Extension
-
setValue
public static void setValue(TaggedValue taggedValue, @CheckForNull java.lang.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
public static void setValue(TaggedValue taggedValue, @CheckForNull java.lang.Object value)
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
public static void clearValue(Element element, @CheckForNull Property tag)
Clears value of tagged value and disposes the tagged value- Parameters:
element
- stereotyped elementtag
- tag definition
-
clearValue
public static void clearValue(TaggedValue taggedValue, boolean disposeTaggedValue)
Clear value of given tagged value- Parameters:
taggedValue
- tagged valuedisposeTaggedValue
- dispose tagged value, not just clear values¬
-
appliedStereotypes
private static com.nomagic.magicdraw.uml2.ProfilesInternal.AppliedStereotypes appliedStereotypes()
-
-