Class TagsHelper

    • Constructor Detail

      • TagsHelper

        public TagsHelper()
    • Method Detail

      • getStereotypePropertyStringValue

        public static java.lang.String getStereotypePropertyStringValue​(@CheckForNull
                                                                        java.lang.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
                                                  java.lang.Object value)
        Removes value from given TaggedValue.
        Parameters:
        taggedValue - the given TaggedValue
        value - value to remove
      • addTaggedValueValue

        public static boolean addTaggedValueValue​(TaggedValue taggedValue,
                                                  java.lang.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,
                                                  java.lang.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,
                                                  java.lang.String tagName,
                                                  java.lang.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
                                                 java.lang.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,
                                                 java.lang.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,
                                                         java.lang.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,
                                               java.util.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:
        java.lang.IllegalArgumentException - if element is null or second argument is not Stereotype
      • getStereotypePropertyValueAsString

        public static java.util.List<java.lang.String> getStereotypePropertyValueAsString​(Element element,
                                                                                          @CheckForNull
                                                                                          Stereotype stereotype,
                                                                                          java.lang.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 java.util.List<java.lang.String> getStereotypePropertyValueAsString​(Element element,
                                                                                          @CheckForNull
                                                                                          Stereotype stereotype,
                                                                                          java.lang.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 java.util.List getStereotypePropertyValue​(Element element,
                                                                @CheckForNull
                                                                Stereotype stereotype,
                                                                java.lang.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 java.util.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 java.util.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 java.util.List getStereotypePropertyValue​(Element element,
                                                                @CheckForNull
                                                                Stereotype stereotype,
                                                                java.lang.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,
                                                      java.lang.String tagName,
                                                      @CheckForNull
                                                      java.lang.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,
                                                                            java.lang.String tagName,
                                                                            @CheckForNull
                                                                            T value,
                                                                            boolean appendValues,
                                                                            @CheckForNull
                                                                            java.util.function.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,
                                                      java.lang.String tagName,
                                                      @CheckForNull
                                                      java.lang.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,
                                                      java.lang.String tagName,
                                                      @CheckForNull
                                                      java.lang.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
                                                      java.lang.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
                                                      java.lang.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
                                                      java.lang.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,
                                                 java.lang.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 java.util.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,
                                                   java.lang.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,
                                                   java.lang.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 java.lang.Object getStereotypePropertyFirst​(Element element,
                                                                  @CheckForNull
                                                                  Stereotype stereotype,
                                                                  java.lang.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 java.lang.Object getStereotypePropertyFirst​(Element element,
                                                                  @CheckForNull
                                                                  Stereotype stereotype,
                                                                  java.lang.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 java.lang.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 java.lang.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 java.util.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 java.util.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