Class StereotypesHelper


@OpenApiAll public class StereotypesHelper extends TagsHelper
A helper class used to work with stereotypes and tagged values. This helper provides a lot of methods for applying stereotypes to elements, creating tagged values or setting values for tags.

  • Field Details

    • UML2METAMODEL

      public static final String UML2METAMODEL
      Name of UML2 metamodel
      See Also:
    • UML2METAMODEL_URI

      public static final String UML2METAMODEL_URI
      URI of UML2 metamodel, must correspond UML standard profile metamodel uri.
      See Also:
    • UML2METAMODEL_PRIMITIVE_TYPES

      public static final String UML2METAMODEL_PRIMITIVE_TYPES
      Name of primitives package in the UML2 metamodel
      See Also:
  • Constructor Details

    • StereotypesHelper

      public StereotypesHelper()
  • Method Details

    • getAllProfiles

      public static Collection<Profile> getAllProfiles(Project project)
      Returns list of all loaded profiles. Returning writable copy.
      Parameters:
      project - project
      Returns:
      list of all loaded profiles
    • getProfile

      @CheckForNull public static Profile getProfile(Project project, String profileName)
      Returns profile element by name
      Parameters:
      project - project
      profileName - profile name
      Returns:
      profile element or null if profile not found
    • getProfileByURI

      @CheckForNull public static Profile getProfileByURI(Project project, String profileURI)
      Returns profile element by URI
      Parameters:
      project - project
      profileURI - profile uri
      Returns:
      profile element or null if profile not found
    • getProfiles

      public static Collection<Profile> getProfiles(Project project, @CheckForNull String profileName)
      Filters all given project profiles by name.
      Parameters:
      project - given project
      profileName - the profile name
      Returns:
      list of profiles that name corresponds to the given profile name
    • getStereotypes

      public static List<Stereotype> getStereotypes(Element element) throws IllegalArgumentException
      Returns all stereotypes applied to element.
      Parameters:
      element - element
      Returns:
      applied stereotypes for this element or empty list if there are no applied stereotypes
      Throws:
      IllegalArgumentException - if element is null
    • hasStereotype

      public static boolean hasStereotype(Element element) throws IllegalArgumentException
      Checks if element has applied stereotypes
      Parameters:
      element - element
      Returns:
      true if has applied stereotype
      Throws:
      IllegalArgumentException - if element is null
    • hasStereotype

      public static boolean hasStereotype(Element element, @CheckForNull Stereotype stereotype) throws IllegalArgumentException
      Checks if element has applied stereotype.
      Parameters:
      element - element
      stereotype - stereotype name to check
      Returns:
      true if element has applied stereotype
      Throws:
      IllegalArgumentException - if element is null
    • hasStereotype

      public static boolean hasStereotype(Element element, Collection<Stereotype> stereotypes) throws IllegalArgumentException
      Checks if element has applied at least one stereotype from given collection of Stereotypes.
      Parameters:
      element - element
      stereotypes - a collection of stereotypes
      Returns:
      true if element has applied at least one stereotype from the given collection
      Throws:
      IllegalArgumentException - if element is null
    • addStereotype

      public static void addStereotype(Element element, Stereotype stereotype) throws IllegalArgumentException
      Applies stereotype to a given element. The default tag values are not created, to create these values use TagsHelper.createDefaultValues(Element, Stereotype, boolean).
      Parameters:
      element - element
      stereotype - stereotype to apply
      Throws:
      IllegalArgumentException - if element or stereotype is null, or element is disposed
    • addStereotype

      public static void addStereotype(Element element, Stereotype stereotype, int index) throws IllegalArgumentException
      Applies stereotype to a given element. The default tag values are not created, to create these values use TagsHelper.createDefaultValues(Element, Stereotype, boolean).
      Parameters:
      element - element
      stereotype - stereotype to apply
      index - index of the stereotype
      Throws:
      IllegalArgumentException - if element or stereotype is null
    • addStereotypes

      public static void addStereotypes(Element element, Collection<Stereotype> stereotypes) throws IllegalArgumentException
      Applies stereotypes from collection for specified element. The default tag values are not created, to create these values use TagsHelper.createDefaultValues(Element, Stereotype, boolean).
      Parameters:
      element - element on which stereotypes are applied
      stereotypes - collection of Stereotype objects
      Throws:
      IllegalArgumentException - if element or stereotypes is null
    • removeStereotype

      public static void removeStereotype(@CheckForNull Element element, @CheckForNull Stereotype stereotype) throws IllegalArgumentException
      Remove applied stereotype from element.
      Parameters:
      element - element
      stereotype - stereotype to remove
      Throws:
      IllegalArgumentException - if element or stereotype is null
    • removeStereotypes

      public static void removeStereotypes(Element element) throws IllegalArgumentException
      Removes all applied stereotypes from element.
      Parameters:
      element - element
      Throws:
      IllegalArgumentException - if element is null
    • removeStereotypes

      public static void removeStereotypes(Element element, Collection<Stereotype> stereotypes) throws IllegalArgumentException
      Removes all stereotypes from element.
      Parameters:
      element - element
      stereotypes - collection of stereotypes to remove
      Throws:
      IllegalArgumentException - if element or stereotypes is null
    • getAppliedStereotypeByString

      @CheckForNull public static Stereotype getAppliedStereotypeByString(Element element, String stereotypeName)
      Returns stereotype applied to element with given name.
      Parameters:
      element - element
      stereotypeName - name of stereotype
      Returns:
      applied stereotype with that name
    • getStereotype

      @CheckForNull public static Stereotype getStereotype(Project project, String stereotypeName, @CheckForNull Profile profile)
      Returns stereotype for given name by profile. First search is performed directly in given profile and if no stereotype is found, then sub profiles are checked.
      Parameters:
      project - project
      stereotypeName - name of stereotype
      profile - stereotype's profile, null if any
      Returns:
      stereotype
    • getStereotypedElementsIncludingDerived

      public static Collection<Element> getStereotypedElementsIncludingDerived(@CheckForNull 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
    • getStereotypedElements

      public static List<Element> getStereotypedElements(@CheckForNull Stereotype stereotype)
      Returns all elements stereotyped by stereotype
      Parameters:
      stereotype - stereotype
      Returns:
      list of elements stereotyped by stereotype
    • hasStereotypedElements

      public static boolean hasStereotypedElements(Stereotype stereotype)
      Checks if stereotype has stereotyped elements
      Parameters:
      stereotype - stereotype to check
      Returns:
      true if stereotype has stereotyped elements
    • getFirstStereotypeWithIcon

      @CheckForNull public static Stereotype getFirstStereotypeWithIcon(Collection<? extends Stereotype> collectionOfStereotypes)
      Returns first stereotype with icon from given collection of stereotypes.
      Parameters:
      collectionOfStereotypes - a collection of stereotypes
      Returns:
      first stereotype with icon
    • getFirstStereotypeWithIcon

      @CheckForNull public static Stereotype getFirstStereotypeWithIcon(Collection<? extends Stereotype> collectionOfStereotypes, boolean includeInvisible)
      Returns first stereotype with icon from given collection of stereotypes.
      Parameters:
      collectionOfStereotypes - a collection of stereotypes
      includeInvisible - indicates whether invisible stereotypes should be taken into account
      Returns:
      first stereotype with icon
    • getFirstVisibleStereotype

      @CheckForNull public static Stereotype getFirstVisibleStereotype(Element element)
      Returns first visible stereotype applied to given element.
      Parameters:
      element - given element
      Returns:
      first visible stereotype
    • getFirstVisibleStereotype

      @CheckForNull public static Stereotype getFirstVisibleStereotype(Collection<? extends Stereotype> stereotypes)
      Returns first visible stereotype from given collection of stereotypes.
      Parameters:
      stereotypes - a collection of stereotypes.
      Returns:
      first visible stereotype.
    • getAllStereotypes

      public static Collection<Stereotype> getAllStereotypes(Project project)
      Returns collection of all stereotypes
      Parameters:
      project - project
      Returns:
      collection of all stereotypes
    • findCommonAssignedStereotypes

      public static List<Stereotype> findCommonAssignedStereotypes(Collection<? extends Element> elements)
      Finds common applied stereotypes for list of collection
      Parameters:
      elements - collection of elements
      Returns:
      common stereotypes
    • getAllAssignedStereotypes

      public static Collection<Stereotype> getAllAssignedStereotypes(Collection<? extends Element> elements)
      Returns all applied stereotypes for elements of collection
      Parameters:
      elements - collection of elements
      Returns:
      all applied stereotypes
    • getExtension

      @CheckForNull public static Extension getExtension(Stereotype stereotype, Class baseClass)
      Checks if stereotype has baseClass as METACLASS
      Parameters:
      stereotype - stereotype
      baseClass - meta class
      Returns:
      extension for base class
    • getExtensions

      public static Collection<Extension> getExtensions(Stereotype stereotype, Class baseClass)
      Collects Extensions connected to this stereotype.
      Parameters:
      stereotype - Stereotype
      baseClass - Base class.
      Returns:
      List of extension.
    • getExtensions

      public static Collection<Extension> getExtensions(Stereotype stereotype, Class baseClass, boolean takeInherited)
      Get Extension Meta Property.
      Parameters:
      stereotype - Stereotype
      baseClass - Base class.
      takeInherited - collect inherited extension ends also
      Returns:
      List of extension.
    • getBaseClasses

      public static List<Class> getBaseClasses(@CheckForNull Stereotype stereotype)
      Returns all base (meta) classes for stereotype
      Parameters:
      stereotype - stereotype
      Returns:
      collection(Class) of base (meta) classes
    • getBaseClasses

      public static List<Class> getBaseClasses(@CheckForNull Stereotype stereotype, boolean includeFromParentStereotypes)
      Returns all base (meta) classes for stereotype
      Parameters:
      stereotype - stereotype
      includeFromParentStereotypes - also take bases classes from parent stereotypes
      Returns:
      collection(Class) of base (meta) classes
    • getSettableStereotypes

      public static Collection<Stereotype> getSettableStereotypes(Project project, String elementType, boolean includeSuperTypes)
      Returns collection of settable stereotypes for element type
      Parameters:
      project - project
      elementType - element type
      includeSuperTypes - include super types also
      Returns:
      collection of settable stereotypes
    • getSettableStereotypes

      public static Collection<Stereotype> getSettableStereotypes(Project project, Collection<? extends Element> elements, boolean includeSuperTypes)
      Returns collection of settable stereotypes for collection of elements
      Parameters:
      project - project
      elements - collection of elements
      includeSuperTypes - include super types also
      Returns:
      collection of settable stereotypes
    • getUML2MetaModel

      @CheckForNull public static Model getUML2MetaModel(Project project)
      Returns model element for UML2 meta model
      Parameters:
      project - project
      Returns:
      model element for UML2 meta model
    • isBuiltInUML2Metamodel

      public static boolean isBuiltInUML2Metamodel(Model model)
      Checks if given model is built in (not user modeled) UML metamodel. Built in metamodel is loaded from standard profile.
      Parameters:
      model - model to check
      Returns:
      true if model is built in uml model
    • getAllMetaModels

      public static Collection<Model> getAllMetaModels(Project project)
      Returns collection of all model elements
      Parameters:
      project - project
      Returns:
      collection of all model elements
    • getMetaModelByName

      @CheckForNull public static Model getMetaModelByName(Project project, String name)
      Return meta model with specified name.
      Parameters:
      project - project to search for meta model.
      name - name meta model name.
      Returns:
      meta model with specified name. null if not found.
    • getAllMetaClasses

      public static Collection<Class> getAllMetaClasses(Project project)
      Returns collection of all meta model classes
      Parameters:
      project - project
      Returns:
      collection of all meta model classes
    • getUML2MetaClasses

      public static Collection<Class> getUML2MetaClasses(Project project)
      Returns collection of all UML2 meta classes
      Parameters:
      project - project
      Returns:
      collection of all UML2 meta classes
    • getMetaClasses

      public static Collection<Class> getMetaClasses(Collection<? extends Model> models)
      Returns meta classes by collection of models
      Parameters:
      models - collection of models
      Returns:
      collection(Class) of meta classes
    • getNamesOfMetaClasses

      public static Collection<String> getNamesOfMetaClasses(Collection<? extends Model> models)
      Returns names of meta classes by collection of models
      Parameters:
      models - collection of models
      Returns:
      collection(String) of meta classes
    • getMetaClassByName

      @CheckForNull public static Class getMetaClassByName(Project project, String name)
      Returns meta class by name
      Parameters:
      project - project
      name - name of meta class
      Returns:
      Class element of meta class
    • getMetaClassByName

      @CheckForNull public static Class getMetaClassByName(String name, Collection<Model> models)
      Returns meta class by name from collection of models
      Parameters:
      name - name of meta class
      models - collection of models to look for
      Returns:
      Class element of meta class
    • getMetaClassesFromPackageByName

      @CheckForNull public static Class getMetaClassesFromPackageByName(Package pkg, String name)
      Search for class in given scope(package) by class name. Search is using query.
      Parameters:
      pkg - Package instance.
      name - Class name
      Returns:
      UML Class or null.
    • getUML2MetaClassByName

      @CheckForNull public static Class getUML2MetaClassByName(Project project, String name)
      /** Returns meta class from UML2 meta model by name
      Parameters:
      project - given project
      name - name of meta class
      Returns:
      Class element of meta class
    • getMetaModelByMetaClass

      @CheckForNull public static Model getMetaModelByMetaClass(Class metaClass)
      Returns meta model of specified meta class.
      Parameters:
      metaClass - meta class
      Returns:
      meta model of meta class. null if c is not meta class
    • getMetaModelByElement

      @CheckForNull public static Model getMetaModelByElement(Element element)
      Returns meta model of specified element in the meta model. Method is expanded to support enumerations and literals from model.
      Parameters:
      element - meta class or other meta element.
      Returns:
      meta model of meta class. null if element is not meta class
    • isMetaClass

      public static boolean isMetaClass(Element element)
      Checks if given element is a meta class, including user defined meta classes. For pure uml meta class use isUML2MetaClass(Class)
      Parameters:
      element - class
      Returns:
      true if element is meta class
    • isMetaClass

      public static boolean isMetaClass(Class aClass)
      Checks if Class is meta class, including user defined meta classes. For pure uml meta class use isUML2MetaClass(Class)
      Parameters:
      aClass - class
      Returns:
      true if Class is meta class
    • isUML2MetaClass

      public static boolean isUML2MetaClass(Class aClass)
      Checks if Class is meta class, and this meta class represents currently instantiated UML model.
      Parameters:
      aClass - class
      Returns:
      true if Class is uml 2 meta class.
    • setBaseClassesByName

      public static void setBaseClassesByName(Stereotype stereotype, Collection<String> metaClasses)
      Sets base (meta) classes for stereotype by names
      Parameters:
      stereotype - stereotype
      metaClasses - collection of meta classes names
    • setBaseClasses

      public static void setBaseClasses(Stereotype stereotype, Collection<Class> metaClasses)
      Sets base (meta) classes for stereotype
      Parameters:
      stereotype - stereotype
      metaClasses - collection of meta classes
    • setBaseClass

      @CheckForNull public static Extension setBaseClass(Stereotype stereotype, @CheckForNull Class metaClass, @CheckForNull Extension extension)
      Sets base (meta) class for stereotype
      Parameters:
      stereotype - stereotype
      metaClass - meta class
      extension - extension for class and stereotype
      Returns:
      created Extension
    • removeBaseClass

      public static void removeBaseClass(Stereotype stereotype, @CheckForNull Class metaClass)
      removes base (meta) class for stereotype
      Parameters:
      stereotype - stereotype
      metaClass - meta class
    • createStereotype

      @CheckForNull public static Stereotype createStereotype(Element owner, String name, Collection<Class> metaClasses)
      Creates stereotype instance and sets base classes for it
      Parameters:
      owner - owner of stereotype
      name - name of stereotype
      metaClasses - meta classes for stereotype
      Returns:
      stereotype
    • createStereotype

      @CheckForNull public static Stereotype createStereotype(Project project, String name, Collection<Class> metaClasses)
      Creates stereotype instance and sets base classes for it
      Parameters:
      project - project
      name - name of stereotype
      metaClasses - meta classes for stereotype
      Returns:
      created stereotype
    • getDefaultMetaClasses

      public static Collection<Class> getDefaultMetaClasses(Project project)
      Dummy procedure for setting of meta classes
      Parameters:
      project - project
      Returns:
      default meta class
    • getNamesOfSuperClasses

      public static Collection<String> getNamesOfSuperClasses(Class aClass)
      Returns names of supper classes for meta class
      Parameters:
      aClass - meta class UML class
      Returns:
      collection of names
    • canApplyStereotype

      public static boolean canApplyStereotype(@CheckForNull Element element, @CheckForNull Stereotype stereotype)
      Checks if stereotype can be applied to element
      Parameters:
      element - element
      stereotype - stereotype
      Returns:
      true if stereotype can be applied to element
    • getIcon

      @CheckForNull public static ResizableIcon getIcon(@CheckForNull Stereotype stereotype)
      Returns ICON from stereotype
      Parameters:
      stereotype - stereotype
      Returns:
      icon
    • deriveStereotype

      public static void deriveStereotype(Stereotype parent, Stereotype child)
      Derives stereotype from other stereotype.
      Parameters:
      parent - parent stereotype
      child - child stereotype
    • getMetaClassByClass

      @CheckForNull public static Class getMetaClassByClass(Project project, Class clazz)
      Returns meta class by given class.
      Parameters:
      project - project
      clazz - class from which to get name from
      Returns:
      meta class
    • getMetaClassesByClass

      public static List<Class> getMetaClassesByClass(Project project, Collection<Class> classes)
      Returns names of meta classes from collection
      Parameters:
      project - project
      classes - collection of meta classes to get names from
      Returns:
      collection of names
    • getBaseClass

      @CheckForNull public static Class getBaseClass(Element element)
      Returns meta class of given element.
      Parameters:
      element - given element
      Returns:
      Class element of meta class
    • getUML2BaseClass

      @CheckForNull public static Class getUML2BaseClass(Element element)
      Returns UML2 metamodel metaclass for a given Element.
      Parameters:
      element - given element
      Returns:
      Class element of meta class
    • getUML2BaseClassByJavaClass

      @CheckForNull public static Class getUML2BaseClassByJavaClass(Project project, Class javaClass)
      Returns UML2 metamodel metaclass for a given Java class.
      Parameters:
      project - project
      javaClass - given Java Class
      Returns:
      Class element of meta class
    • getBaseClassesAsClasses

      public static Collection<Class> getBaseClassesAsClasses(@CheckForNull Stereotype stereotype)
      Returns collection(java.lang.Class) of metaclasses from stereotype
      Parameters:
      stereotype - stereotype
      Returns:
      collection of meta classes
    • canAssignStereotype

      public static boolean canAssignStereotype(Element element, Stereotype stereotype)
      Indicates if stereotype can be applied to a given element.

      - checks if stereotype meta class fits class of an element.

      Parameters:
      element - element to which stereotype should be applied.
      stereotype - stereotype to assign.
      Returns:
      true if stereotype can applied, false otherwise.
    • isInvisible

      public static boolean isInvisible(@CheckForNull RedefinableElement element)
      Check is element is invisible (has Invisible stereotype or one of it's children)
      Parameters:
      element - element
      Returns:
      true if element is invisible
      See Also:
    • canApplyProfile

      public static boolean canApplyProfile(Package pkg, Profile profile)
      Checks profile can apply to package.
      Parameters:
      pkg - The given package.
      profile - The given profile.
      Returns:
      boolean
    • applyProfile

      public static void applyProfile(Package pkg, Profile profile)
      Applies profile to the package
      Parameters:
      pkg - package
      profile - profile to apply
    • removeProfile

      public static void removeProfile(Package pkg, Profile profile)
      Removes profile application from the package
      Parameters:
      pkg - package
      profile - applied profile
    • getStereotypesByProfile

      public static Collection<Stereotype> getStereotypesByProfile(Profile profile)
      Returns collection of stereotypes by profile
      Parameters:
      profile - profile
      Returns:
      collection of stereotypes by profile
    • isRequiredStereotypeForElement

      public static boolean isRequiredStereotypeForElement(Stereotype stereotype, Element element)
      Checks if stereotype is required for element
      Parameters:
      stereotype - stereotype
      element - element
      Returns:
      true if stereotype is required for element
    • getClassOfMetaClass

      public static Class getClassOfMetaClass(Class metaClass)
      Returns java.lang.Class for meta class by Class
      Parameters:
      metaClass - meta class
      Returns:
      java.lang.Class for meta class
    • applyProfiles

      public static void applyProfiles(Package pkg, Collection<Profile> profiles)
      Applies profiles from collection to specified package
      Parameters:
      pkg - package
      profiles - list of profiles
    • removeProfiles

      public static void removeProfiles(@CheckForNull Package pkg, @CheckForNull Collection<Profile> profiles)
      Removes applied profiles in package from collection
      Parameters:
      pkg - package
      profiles - collection of profiles
    • getAppliedProfiles

      public static Collection<Profile> getAppliedProfiles(@CheckForNull Package pkg)
      Returns collection of applied profiles on package
      Parameters:
      pkg - package
      Returns:
      collection of applied profiles
    • canRemoveProfile

      public static boolean canRemoveProfile(Package pkg, Profile profile)
      Checks if it is possible to remove applied profile from package
      Parameters:
      pkg - package
      profile - profile
      Returns:
      true if it is possible to remove applied profile
    • getDependingProfiles

      public static Collection<Profile> getDependingProfiles(Profile profile)
      Returns collection of depending profile for profile
      Parameters:
      profile - profile
      Returns:
      collection of depending profile
    • checkForDerivedStereotype

      @CheckForNull public static Stereotype checkForDerivedStereotype(Element element, Stereotype stereotype)
      Checks if the given stereotype or it's child is already applied to the element.
      Parameters:
      element - element
      stereotype - stereotype
      Returns:
      given stereotype or it's child applied to element
    • checkForDerivedStereotype

      @CheckForNull public static Stereotype checkForDerivedStereotype(Element element, Collection<Stereotype> stereotypes)
      Checks if there are child of at least one given stereotype already set to given element
      Parameters:
      element - element
      stereotypes - a collection of stereotypes to check
      Returns:
      stereotype or child of stereotype applied to element
    • checkForDerivedStereotype

      @CheckForNull public static Stereotype checkForDerivedStereotype(Collection<Stereotype> stereotypes, Stereotype parent)
      Checks if there are given stereotype or derived stereotype in a given stereotypes collection.
      Parameters:
      stereotypes - collection of stereotypes to look in
      parent - parent stereotype
      Returns:
      returns stereotype which equals to the given or is derived
    • getDerivedStereotypes

      public static Collection<Stereotype> getDerivedStereotypes(Element element, Stereotype parent, boolean includeParent)
      Returns applied derived stereotypes
      Parameters:
      element - element
      parent - stereotype
      includeParent - true if include parent stereotype in collection
      Returns:
      stereotype or child of stereotype for element
    • hasStereotypeOrDerived

      public static boolean hasStereotypeOrDerived(Element element, @CheckForNull Stereotype stereotype)
      Checks if there are child of parent stereotype already set
      Parameters:
      element - element
      stereotype - stereotype
      Returns:
      true if at least one child of parent is set for element
    • hasStereotypeOrDerived

      public static boolean hasStereotypeOrDerived(Element element, Collection<Stereotype> stereotypes) throws IllegalArgumentException
      Checks if element has applied at least one stereotype(or derived) from given collection of Stereotypes.
      Parameters:
      element - element to check
      stereotypes - a collection of stereotypes
      Returns:
      true if element has applied at least one stereotype from given collection
      Throws:
      IllegalArgumentException - if element is null
    • getStereotypesByMetaClasses

      public static Set<Stereotype> getStereotypesByMetaClasses(Collection<Class> metaClasses)
      Collects stereotypes which extend given meta classes.
      Parameters:
      metaClasses - meta classes
      Returns:
      stereotypes
    • getExtensionEnd

      @CheckForNull public static ExtensionEnd getExtensionEnd(Extension extension)
      ExtensionEnd of given Extension
      Parameters:
      extension - Extension
      Returns:
      ExtensionEnd of Extension
    • assignImageFilesToStereotype

      public static void assignImageFilesToStereotype(Stereotype stereotype, Collection<File> files)
      Assigns given image files to stereotype as icons.
      Parameters:
      stereotype - stereotype to which icons should be applied
      files - image files to assign
    • getDerivedStereotypesRecursively

      public static List<Stereotype> getDerivedStereotypesRecursively(Stereotype stereotype)
      Returns derived stereotypes recursively
      Parameters:
      stereotype - stereotype for which to return derived stereotypes
      Returns:
      list of derived stereotypes
    • getElementsRequiresExtension

      public static Collection<Element> getElementsRequiresExtension(Extension extension)
      Checks which stereotyped elements requires this extension (it provides base class for stereotyped element).
      Parameters:
      extension - extension to check.
      Returns:
      elements which uses given extension.
    • getAssignedMetaClassOfSubtype

      public static List<Class> getAssignedMetaClassOfSubtype(Stereotype stereotype, Class meta)
      Collect all subtypes of given meta classes whose are extended by a given stereotype
      Parameters:
      stereotype - stereotype
      meta - meta class
      Returns:
      meta classes
    • hasSuperMetaClass

      public static boolean hasSuperMetaClass(Stereotype stereotype, Class meta)
      Checks if stereotype has super meta class.
      Parameters:
      stereotype - stereotype
      meta - meta class
      Returns:
      true if stereotype has super meta class.
    • removeSuperMetaClasses

      public static void removeSuperMetaClasses(Stereotype stereotype, Class meta)
      Remove super meta class from the given stereotype.
      Parameters:
      stereotype - stereotype
      meta - meta class
    • isExtensionProperty

      public static boolean isExtensionProperty(Property property)
      Parameters:
      property - property
      Returns:
      true if given property is memberEnd of Extension
    • getProfileForStereotype

      @CheckForNull public static Package getProfileForStereotype(Stereotype stereotype)
      Returns profile for a given stereotype.
      Parameters:
      stereotype - stereotype
      Returns:
      profile where given stereotype is defined. If it has profile parent it is defined in profile, in other case parent package will be return.
    • getExtensionMetaProperty

      public static Collection<Property> getExtensionMetaProperty(Stereotype stereotype)
      Collects properties of MetaClass extension end
      Parameters:
      stereotype - stereotype to check for meta classes
      Returns:
      collection of properties.
    • getExtensionMetaProperty

      public static Collection<Property> getExtensionMetaProperty(Stereotype stereotype, boolean includeInherited)
      Collects properties of MetaClass extension end
      Parameters:
      stereotype - stereotype to check for meta classes
      includeInherited - collection inherited meta properties
      Returns:
      collection of properties.
    • isFromPrimitiveTypes

      public static boolean isFromPrimitiveTypes(Element element)
      Checks if given element is from UML2 metamodel primitive types package
      Parameters:
      element - the given element
      Returns:
      true, if given element is from primitive types package.
    • getPrimitiveTypesPackage

      @CheckForNull public static Package getPrimitiveTypesPackage(Project project)
      Returns primitive types package of UML2 metamodel.
      Parameters:
      project - project.
      Returns:
      primitive types package.
    • getPrimitiveByName

      @CheckForNull public static PrimitiveType getPrimitiveByName(Project project, String name)
      Finds primitiveType by name
      Parameters:
      project - project where find primitive.
      name - primitive name.
      Returns:
      Primitive with given name.
    • hasVisibleStereotype

      public static boolean hasVisibleStereotype(Element element)
      Check if given element has at least one visible stereotype.
      Parameters:
      element - given element
      Returns:
      true if visible stereotype is applied to the given element
      See Also:
    • filterVisibleStereotypes

      @CheckForNull public static Collection<Stereotype> filterVisibleStereotypes(@CheckForNull Collection<Stereotype> stereotypes)
      Filter stereotypes from given collection whose are "visible". Stereotype is visible if it is not derived from <>
      Parameters:
      stereotypes - collection of stereotypes
      Returns:
      new collection of visible stereotypes
      See Also:
    • filterVisibleElement

      @CheckForNull public static Collection<? extends Element> filterVisibleElement(@CheckForNull Collection<? extends Element> elements)
      Filter elements from given collection whose are "visible". Element is visible if it does not have applied stereotype <>
      Parameters:
      elements - collection of elements
      Returns:
      new collection of visible elements
      See Also:
    • optimizeStereotypes

      public static void optimizeStereotypes(Element element)
      Optimize applied stereotypes to an Element by removing more general stereotypes if more specific are applied. This rule is applied only for stereotypes whose "hideMetatype" in DSL configuration
      Parameters:
      element - element
    • isTypeOf

      public static boolean isTypeOf(Element element, Collection<Classifier> typesCollection, boolean includeInherited)
      Checks if element is of type from typesCollection. 3 scenarios can be tested 1. Element is of specified type or inherited 2. Element has applied stereotype or inherited stereotype 3. InstanceSpecification has Classifier instance or inherited .
      Parameters:
      element - instance that type will be checked.
      typesCollection - collection of types used to check if element type is part of it
      includeInherited - if set to true all element type hierarchy will be checked against typesCollection
      Returns:
      true if element is of type from typesCollection
    • isTypeOf

      public static boolean isTypeOf(Element element, Collection<Classifier> typesCollection, boolean includeInherited, boolean includeCustomTypes)
      Checks if element is of type from typesCollection. 3 scenarios can be tested 1. Element is of specified type or inherited 2. Element has applied stereotype or inherited stereotype 3. InstanceSpecification has Classifier instance or inherited .
      Parameters:
      element - instance that type will be checked
      typesCollection - collection of types used to check if element type is part of it
      includeInherited - if set to true all element type hierarchy will be checked against typesCollection
      includeCustomTypes - check against custom types
      Returns:
      true if element is of type from typesCollection
    • getTypeClasses

      public static Collection<Object> getTypeClasses(Collection<Element> elementTypes)
      Converts Meta Class elements to java.lang.Class objects, stereotypes are left unchanged.
      Parameters:
      elementTypes - MetaType classes and stereotypes
      Returns:
      java.lang.Class objects and stereotypes.
    • getTypeClasses

      public static Set<Object> getTypeClasses(Collection<? extends Element> elementTypes, boolean includeSubtypes, boolean expandAbstract)
      Converts Meta Class elements to java.lang.Class objects, stereotypes are left unchanged.
      Parameters:
      elementTypes - MetaType classes and stereotypes
      includeSubtypes - if true derived stereotypes and metaClasses will be collected.
      expandAbstract - if true and abstract metaClasses subtypes will be collected.
      Returns:
      java.lang.Class objects and stereotypes.
    • isOfType

      public static boolean isOfType(Element element, Collection<Class> metaTypes, boolean checkDSL)
      Checks if element is of type from given meta-types
      Parameters:
      element - instance that type will be checked
      metaTypes - meta types
      checkDSL - take DSL rules into account
      Returns:
      true if element is of type from typesCollection