Class TagsHelper

Direct Known Subclasses:
StereotypesHelper

@OpenApiAll public class TagsHelper extends DeprecatedStereotypesHelper
Utility class to work with tagged values.
  • Constructor Details

    • TagsHelper

      public TagsHelper()
  • Method Details

    • getStereotypePropertyStringValue

      public static String getStereotypePropertyStringValue(@CheckForNull Object o)
      Converts given stereotype property value to a string.
      Parameters:
      o - value object
      Returns:
      string representation of given value object
    • getTagDefinitionOwner

      @CheckForNull public static Stereotype getTagDefinitionOwner(TaggedValue taggedValue)
      Returns stereotype owning tag definition of given tagged value.
      Parameters:
      taggedValue - the given TaggedValue
      Returns:
      stereotype owning tag definition of given tagged value
    • removeTaggedValueValue

      public static void removeTaggedValueValue(@CheckForNull TaggedValue taggedValue, @CheckForNull Object value)
      Removes value from given TaggedValue.
      Parameters:
      taggedValue - the given TaggedValue
      value - value to remove
    • addTaggedValueValue

      public static boolean addTaggedValueValue(TaggedValue taggedValue, Object value, boolean append)
      Add value to the given TaggedValue.
      Parameters:
      taggedValue - the given TaggedValue
      value - value to add
      append - True - Don't remove the append value
      Returns:
      true if succeeded
    • addTaggedValueValue

      public static boolean addTaggedValueValue(TaggedValue taggedValue, Object value, boolean append, boolean setAnotherEnd)
      Add value to the given TaggedValue.
      Parameters:
      taggedValue - the given TaggedValue
      value - value
      append - True - Don't remove the append value
      setAnotherEnd - set another meta association end value
      Returns:
      true if succeeded
    • removeTaggedValueValue

      public static void removeTaggedValueValue(Element element, Stereotype stereotype, String tagName, Object value)
      Removes a value from the tagged value.
      Parameters:
      element - element which has the tagged value
      stereotype - stereotype which defines the tag
      tagName - tag name
      value - value to remove
    • getPropertyByName

      @CheckForNull public static Property getPropertyByName(@CheckForNull Stereotype stereotype, @CheckForNull String tagName)
      Returns property of stereotype by name
      Parameters:
      stereotype - stereotype to get property from
      tagName - name of tag definition
      Returns:
      property
    • getTaggedValue

      @CheckForNull public static TaggedValue getTaggedValue(Element element, Stereotype stereotype, String tagName)
      Returns tagged value for stereotype tag
      Parameters:
      element - element with applied stereotype
      stereotype - stereotype
      tagName - name of tag definition
      Returns:
      TaggedValue of the tag
    • getTaggedValueOrCreate

      @CheckForNull public static TaggedValue getTaggedValueOrCreate(Element element, Stereotype stereotype, String tagName, boolean createDefaultValue)
      Returns tagged value for stereotype tag
      Parameters:
      element - element with assigned stereotype
      stereotype - stereotype
      tagName - name of tag definition
      createDefaultValue - create default values for a tagged value
      Returns:
      TaggedValue of the tag
    • getTaggedValueOrCreate

      @CheckForNull public static TaggedValue getTaggedValueOrCreate(Element element, Stereotype stereotype, Property tagDefinition, boolean createDefaultValue)
      Returns tagged value for stereotype tag.
      Parameters:
      element - element with assigned stereotype
      stereotype - stereotype
      tagDefinition - tag definition
      createDefaultValue - create default values for a tagged value
      Returns:
      TaggedValue of the tag
    • getTaggedValue

      @CheckForNull public static TaggedValue getTaggedValue(Element element, @CheckForNull Property tagDefinition)
      Returns tagged value for given tag definition.
      Parameters:
      element - element with applied tagged values
      tagDefinition - tag definition
      Returns:
      TaggedValue of the tag
    • createDefaultValues

      public static void createDefaultValues(Element element, Collection<Stereotype> stereotypes, boolean createAll)
      Creates tagged values with default values for given element from given Stereotypes.
      Parameters:
      element - in this element tagged values will be created
      stereotypes - tags providers
      createAll - creates tagged values for all tags (do not check multiplicity). If false, tagged values will be created for tags which have multiplicity lower >=1.
    • createDefaultValues

      public static void createDefaultValues(Element element, Stereotype stereotype, boolean createAll)
      Creates tagged values with default values for given element from given Stereotype.
      Parameters:
      element - in this element tagged values will be created
      stereotype - tags provider
      createAll - creates tagged values for all tags (do not check multiplicity). If false, tagged values will be created for tags which have multiplicity lower >=1.
      Throws:
      IllegalArgumentException - if element is null or second argument is not Stereotype
    • getStereotypePropertyValueAsString

      public static List<String> getStereotypePropertyValueAsString(Element element, @CheckForNull Stereotype stereotype, String tagName)
      Gets tagged values as list of strings.
      Parameters:
      element - element with assigned stereotype
      stereotype - stereotype
      tagName - name of tag definition
      Returns:
      values
    • getStereotypePropertyValueAsString

      public static List<String> getStereotypePropertyValueAsString(Element element, @CheckForNull Stereotype stereotype, String tagName, boolean calculateDerived)
      Gets tagged values as list of strings
      Parameters:
      element - element with applied stereotype
      stereotype - stereotype
      tagName - name of tag definition
      calculateDerived - if to calculate derived property value
      Returns:
      values
    • getStereotypePropertyValue

      public static List getStereotypePropertyValue(Element element, @CheckForNull Stereotype stereotype, String tagName)
      Gets tagged values as list.
      Parameters:
      element - element with applied stereotype
      stereotype - stereotype
      tagName - name of tag definition
      Returns:
      values
    • getStereotypePropertyValue

      public static List getStereotypePropertyValue(Element element, @CheckForNull Property tagDefinition)
      Gets tagged values as list.
      Parameters:
      element - element with applied stereotype
      tagDefinition - tag definition
      Returns:
      values
    • getStereotypePropertyValue

      public static List getStereotypePropertyValue(Element element, @CheckForNull Property tagDefinition, boolean calculateDerived)
      Gets tagged values as list.
      Parameters:
      element - element with applied stereotype
      tagDefinition - property
      calculateDerived - if to calculate derived property value
      Returns:
      values
    • getStereotypePropertyValue

      public static List getStereotypePropertyValue(Element element, @CheckForNull Stereotype stereotype, String tagName, boolean calculateDerived)
      Gets tagged values as list.
      Parameters:
      element - element with applied stereotype
      stereotype - stereotype
      tagName - name of tag definition
      calculateDerived - if to calculate derived property value
      Returns:
      values
    • setStereotypePropertyValue

      public static void setStereotypePropertyValue(Element element, @CheckForNull Stereotype stereotype, String tagName, @CheckForNull Object value, boolean appendValues)
      Sets tagged values.
      Parameters:
      element - element with applied stereotype
      stereotype - name of stereotype
      tagName - name of tag definition
      value - value
      appendValues - append or replace existing values
    • setStereotypePropertyValueWithClearPredicate

      public static <T> void setStereotypePropertyValueWithClearPredicate(Element element, @CheckForNull Stereotype stereotype, String tagName, @CheckForNull T value, boolean appendValues, @CheckForNull Predicate<T> clearValuesPredicate)
      Sets tagged values. If clear predicate is found and true, clears tagged values and removes TaggedValue, otherwise continues on setting tagged value.
      Parameters:
      element - element with applied stereotype
      stereotype - name of stereotype
      tagName - name of tag definition
      value - value
      appendValues - append or replace existing values
      clearValuesPredicate - clear values predicate to check if value needs to be removed
    • setStereotypePropertyValue

      public static void setStereotypePropertyValue(Element element, @CheckForNull Stereotype stereotype, String tagName, @CheckForNull Object value)
      Sets tagged values. Existing values will be replaced.
      Parameters:
      element - element with applied stereotype
      stereotype - name of stereotype
      tagName - name of tag definition
      value - value
    • setStereotypePropertyValue

      public static void setStereotypePropertyValue(Element element, @CheckForNull Stereotype stereotype, String tagName, @CheckForNull Object value, boolean appendValues, boolean setAnotherEnd)
      Sets tagged values.
      Parameters:
      element - element with applied stereotype
      stereotype - stereotype
      tagName - name of tag definition
      value - value
      appendValues - true to leave current value intact and add new one, false to replace current value with new one.
      setAnotherEnd - calculate and change value of another meta association end
    • setStereotypePropertyValue

      public static void setStereotypePropertyValue(Element element, @CheckForNull Stereotype stereotype, @CheckForNull Property tag, @CheckForNull Object value, boolean appendValues)
      Sets tagged values.
      Parameters:
      element - element with applied stereotype
      stereotype - name of stereotype
      tag - tag definition
      value - value
      appendValues - append or replace existing values
    • setStereotypePropertyValue

      public static void setStereotypePropertyValue(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 - name of stereotype
      tag - tag definition
      value - value
    • setStereotypePropertyValue

      public static void setStereotypePropertyValue(Element element, @CheckForNull Stereotype stereotype, @CheckForNull Property tag, @CheckForNull Object value, boolean appendValues, boolean setAnotherEnd)
      Sets tagged values.
      Parameters:
      element - element with applied stereotype
      stereotype - stereotype
      tag - tag definition
      value - value
      appendValues - true to leave current value intact and add new one, false to replace current value with new one.
      setAnotherEnd - calculate and change value of another meta association end
    • getTaggedValue

      @CheckForNull public static TaggedValue getTaggedValue(Element element, String tagName)
      Looks for tagged value with given tag name in the given element.
      Parameters:
      element - element
      tagName - tag name
      Returns:
      tagged value with given tag name in the given element or null
    • isValidTagType

      public static boolean isValidTagType(Type type)
      Check if given type is valid for a tag of a Stereotype. Tag can be typed just by Stereotype, Data Type or metaclass.
      Parameters:
      type - type
      Returns:
      true if valid
    • collectVisibleTaggedValues

      public static List<TaggedValue> collectVisibleTaggedValues(@CheckForNull Element element)
      Returns visible tagged values applied to the element.
      Parameters:
      element - element
      Returns:
      list of visible tagged values
    • hasStereotypePropertyValues

      public static boolean hasStereotypePropertyValues(@CheckForNull Element element)
      Checks if given element has some tagged values.
      Parameters:
      element - given element
      Returns:
      true if some tagged value is created for a given element
    • clearStereotypeProperty

      public static void clearStereotypeProperty(Element element, @CheckForNull Stereotype stereotype, String tagName)
      Clears tagged values.
      Parameters:
      element - element
      stereotype - stereotype
      tagName - name of tag definition
    • clearStereotypeProperty

      public static void clearStereotypeProperty(Element element, @CheckForNull Stereotype stereotype, String tagName, boolean disposeTaggedValue)
      Clears tagged values and removes TaggedValue if needed.
      Parameters:
      element - element
      stereotype - stereotype of property
      tagName - name of tag definition
      disposeTaggedValue - disposes TaggedValue
    • clearStereotypeProperty

      public static void clearStereotypeProperty(Element element, @CheckForNull Property tag)
      Clears tagged values.
      Parameters:
      element - element
      tag - tag definition
    • clearStereotypeProperty

      public static void clearStereotypeProperty(Element element, @CheckForNull Property tag, boolean disposeTaggedValue)
      Clears tagged values and removes TaggedValue if needed.
      Parameters:
      element - element
      tag - tag definition
      disposeTaggedValue - disposes TaggedValue
    • getStereotypePropertyFirst

      @CheckForNull public static Object getStereotypePropertyFirst(Element element, @CheckForNull Stereotype stereotype, String tagName)
      Returns first value of TaggedValue.
      Parameters:
      element - element
      stereotype - stereotype
      tagName - name of tag definition
      Returns:
      first value of TaggedValue
    • getStereotypePropertyFirst

      @CheckForNull public static Object getStereotypePropertyFirst(Element element, @CheckForNull Stereotype stereotype, String tagName, boolean calculateDerived)
      Returns first value of TaggedValue.
      Parameters:
      element - element
      stereotype - stereotype
      tagName - name of tag definition
      calculateDerived - if to calculate derived value
      Returns:
      first value of TaggedValue
    • getStereotypePropertyFirst

      @CheckForNull public static Object getStereotypePropertyFirst(Element element, @CheckForNull Property tag)
      Returns first value of TaggedValue.
      Parameters:
      element - element
      tag - tag definition
      Returns:
      first value of TaggedValue
    • getStereotypePropertyFirst

      @CheckForNull public static Object getStereotypePropertyFirst(Element element, @CheckForNull Property tag, boolean calculateDerived)
      Returns first value of TaggedValue.
      Parameters:
      element - element
      tag - tag definition
      calculateDerived - if to calculate derived value
      Returns:
      first value of TaggedValue
    • getPropertiesWithDerived

      public static Set<Property> getPropertiesWithDerived(Stereotype stereotype)
      Returns properties of stereotype including derived ones. Use this only if you do not care about order of collected properties.
      Parameters:
      stereotype - stereotype
      Returns:
      set of properties
    • getPropertiesWithDerivedOrdered

      public static List<Property> getPropertiesWithDerivedOrdered(Stereotype stereotype)
      Returns properties of stereotype including derived ones, first will be own element properties then parent and so on.
      Parameters:
      stereotype - stereotype
      Returns:
      list of properties