Class Profiles

java.lang.Object
com.nomagic.magicdraw.uml2.Profiles

public class Profiles extends Object
Convenience static methods to work with Stereotyped elements and tagged values. Common for Stereotypes from any Profile.
  • Constructor Details

    • Profiles

      public Profiles()
  • Method Details

    • getStereotypedElements

      public static 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 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 - element
      stereotype - stereotype to check for
      Returns:
      given stereotype or stereotype derived from it, if applied to the element
    • getAppliedStereotypes

      public static Collection<Stereotype> getAppliedStereotypes(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, 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 - element
      stereotypes - 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 - element
      stereotypes - 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 check
      stereotype - 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 use createDefaultValues(Element, Stereotype, boolean)
      Parameters:
      element - element
      stereotype - 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 - element
      stereotype - 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 applied
      stereotype - stereotype applied to the element
      createAll - 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 value
      createAll - 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

      public static 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 stereotype
      tag - property owned by the applied stereotype
      Returns:
      tagged values values (a modifiable copy of original values lists)
    • getFirstValue

      @CheckForNull public static 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 - element
      tag - tag definition
      Returns:
      tagged value
    • setValue

      public static void setValue(Element element, Property tag, @CheckForNull Object value)
      Sets tagged values. Existing values will be replaced.
      Parameters:
      element - element with applied stereotype
      tag - property owned by the stereotype
      value - 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 stereotype
      stereotype - the applied stereotype
      tag - tag definition
      value - 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 stereotype
      stereotype - the applied stereotype
      tag - tag definition
      value - value to set, null is ignored
      setOppositeEnd - 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 Object value)
      Adds tagged values.
      Parameters:
      element - element with applied stereotype
      tag - property owned by the stereotype
      value - 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 stereotype
      stereotype - the applied stereotype
      tag - tag definition
      value - 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 stereotype
      stereotype - the applied stereotype
      tag - tag definition
      value - value to add, null is ignored
      setOppositeEnd - 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 Object value, boolean setOppositeEnd)
      Sets tagged values. Existing values will be replaced.
      Parameters:
      taggedValue - tagged value
      value - value to set
      setOppositeEnd - 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 Object value)
      Sets tagged values. Existing values will be replaced.
      Parameters:
      taggedValue - tagged value
      value - 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 element
      tag - tag definition
      disposeTaggedValue - 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 element
      tag - tag definition
    • clearValue

      public static void clearValue(TaggedValue taggedValue, boolean disposeTaggedValue)
      Clear value of given tagged value
      Parameters:
      taggedValue - tagged value
      disposeTaggedValue - dispose tagged value, not just clear values¬