Package com.nomagic.uml2.ext.jmi.helpers
Class StereotypesHelper
java.lang.Object
com.nomagic.uml2.ext.jmi.helpers.DeprecatedTagsHelper
com.nomagic.uml2.ext.jmi.helpers.DeprecatedStereotypesHelper
com.nomagic.uml2.ext.jmi.helpers.TagsHelper
com.nomagic.uml2.ext.jmi.helpers.StereotypesHelper
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 Summary
Modifier and TypeFieldDescriptionstatic final String
Name of UML2 metamodelstatic final String
Name of primitives package in the UML2 metamodelstatic final String
URI of UML2 metamodel, must correspond UML standard profile metamodel uri.Fields inherited from class com.nomagic.uml2.ext.jmi.helpers.DeprecatedStereotypesHelper
INVISIBLE_STEREOTYPE_NAME, METAMODEL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addStereotype
(Element element, Stereotype stereotype) Applies stereotype to a given element.static void
addStereotype
(Element element, Stereotype stereotype, int index) Applies stereotype to a given element.static void
addStereotypes
(Element element, Collection<Stereotype> stereotypes) Applies stereotypes from collection for specified element.static void
applyProfile
(Package pkg, Profile profile) Applies profile to the packagestatic void
applyProfiles
(Package pkg, Collection<Profile> profiles) Applies profiles from collection to specified packagestatic void
assignImageFilesToStereotype
(Stereotype stereotype, Collection<File> files) Assigns given image files to stereotype as icons.static boolean
canApplyProfile
(Package pkg, Profile profile) Checks profile can apply to package.static boolean
canApplyStereotype
(Element element, Stereotype stereotype) Checks if stereotype can be applied to elementstatic boolean
canAssignStereotype
(Element element, Stereotype stereotype) Indicates if stereotype can be applied to a given element.static boolean
canRemoveProfile
(Package pkg, Profile profile) Checks if it is possible to remove applied profile from packagestatic Stereotype
checkForDerivedStereotype
(Element element, Stereotype stereotype) Checks if the given stereotype or it's child is already applied to the element.static Stereotype
checkForDerivedStereotype
(Element element, Collection<Stereotype> stereotypes) Checks if there are child of at least one given stereotype already set to given elementstatic Stereotype
checkForDerivedStereotype
(Collection<Stereotype> stereotypes, Stereotype parent) Checks if there are given stereotype or derived stereotype in a given stereotypes collection.static Stereotype
createStereotype
(Project project, String name, Collection<Class> metaClasses) Creates stereotype instance and sets base classes for itstatic Stereotype
createStereotype
(Element owner, String name, Collection<Class> metaClasses) Creates stereotype instance and sets base classes for itstatic void
deriveStereotype
(Stereotype parent, Stereotype child) Derives stereotype from other stereotype.static Collection<? extends Element>
filterVisibleElement
(Collection<? extends Element> elements) Filter elements from given collection whose are "visible".static Collection<Stereotype>
filterVisibleStereotypes
(Collection<Stereotype> stereotypes) Filter stereotypes from given collection whose are "visible".static List<Stereotype>
findCommonAssignedStereotypes
(Collection<? extends Element> elements) Finds common applied stereotypes for list of collectionstatic Collection<Stereotype>
getAllAssignedStereotypes
(Collection<? extends Element> elements) Returns all applied stereotypes for elements of collectionstatic Collection<Class>
getAllMetaClasses
(Project project) Returns collection of all meta model classesstatic Collection<Model>
getAllMetaModels
(Project project) Returns collection of all model elementsstatic Collection<Profile>
getAllProfiles
(Project project) Returns list of all loaded profiles.static Collection<Stereotype>
getAllStereotypes
(Project project) Returns collection of all stereotypesstatic Collection<Profile>
Returns collection of applied profiles on packagestatic Stereotype
getAppliedStereotypeByString
(Element element, String stereotypeName) Returns stereotype applied to element with given name.getAssignedMetaClassOfSubtype
(Stereotype stereotype, Class meta) Collect all subtypes of given meta classes whose are extended by a given stereotypestatic Class
getBaseClass
(Element element) Returns meta class of given element.getBaseClasses
(Stereotype stereotype) Returns all base (meta) classes for stereotypegetBaseClasses
(Stereotype stereotype, boolean includeFromParentStereotypes) Returns all base (meta) classes for stereotypestatic Collection<Class>
getBaseClassesAsClasses
(Stereotype stereotype) Returns collection(java.lang.Class) of metaclasses from stereotypestatic Class
getClassOfMetaClass
(Class metaClass) Returns java.lang.Class for meta class by Classstatic Collection<Class>
getDefaultMetaClasses
(Project project) Dummy procedure for setting of meta classesstatic Collection<Profile>
getDependingProfiles
(Profile profile) Returns collection of depending profile for profilestatic Collection<Stereotype>
getDerivedStereotypes
(Element element, Stereotype parent, boolean includeParent) Returns applied derived stereotypesstatic List<Stereotype>
getDerivedStereotypesRecursively
(Stereotype stereotype) Returns derived stereotypes recursivelystatic Collection<Element>
getElementsRequiresExtension
(Extension extension) Checks which stereotyped elements requires this extension (it provides base class for stereotyped element).static Extension
getExtension
(Stereotype stereotype, Class baseClass) Checks if stereotype has baseClass as METACLASSstatic ExtensionEnd
getExtensionEnd
(Extension extension) ExtensionEnd of given Extensionstatic Collection<Property>
getExtensionMetaProperty
(Stereotype stereotype) Collects properties of MetaClass extension endstatic Collection<Property>
getExtensionMetaProperty
(Stereotype stereotype, boolean includeInherited) Collects properties of MetaClass extension endstatic Collection<Extension>
getExtensions
(Stereotype stereotype, Class baseClass) Collects Extensions connected to this stereotype.static Collection<Extension>
getExtensions
(Stereotype stereotype, Class baseClass, boolean takeInherited) Get Extension Meta Property.static Stereotype
getFirstStereotypeWithIcon
(Collection<? extends Stereotype> collectionOfStereotypes) Returns first stereotype with icon from given collection of stereotypes.static Stereotype
getFirstStereotypeWithIcon
(Collection<? extends Stereotype> collectionOfStereotypes, boolean includeInvisible) Returns first stereotype with icon from given collection of stereotypes.static Stereotype
getFirstVisibleStereotype
(Element element) Returns first visible stereotype applied to given element.static Stereotype
getFirstVisibleStereotype
(Collection<? extends Stereotype> stereotypes) Returns first visible stereotype from given collection of stereotypes.static ResizableIcon
getIcon
(Stereotype stereotype) Returns ICON from stereotypestatic Class
getMetaClassByClass
(Project project, Class clazz) Returns meta class by given class.static Class
getMetaClassByName
(Project project, String name) Returns meta class by namestatic Class
getMetaClassByName
(String name, Collection<Model> models) Returns meta class by name from collection of modelsstatic Collection<Class>
getMetaClasses
(Collection<? extends Model> models) Returns meta classes by collection of modelsgetMetaClassesByClass
(Project project, Collection<Class> classes) Returns names of meta classes from collectionstatic Class
getMetaClassesFromPackageByName
(Package pkg, String name) Search for class in given scope(package) by class name.static Model
getMetaModelByElement
(Element element) Returns meta model of specified element in the meta model.static Model
getMetaModelByMetaClass
(Class metaClass) Returns meta model of specified meta class.static Model
getMetaModelByName
(Project project, String name) Return meta model with specified name.static Collection<String>
getNamesOfMetaClasses
(Collection<? extends Model> models) Returns names of meta classes by collection of modelsstatic Collection<String>
getNamesOfSuperClasses
(Class aClass) Returns names of supper classes for meta classstatic PrimitiveType
getPrimitiveByName
(Project project, String name) Finds primitiveType by namestatic Package
getPrimitiveTypesPackage
(Project project) Returns primitive types package of UML2 metamodel.static Profile
getProfile
(Project project, String profileName) Returns profile element by namestatic Profile
getProfileByURI
(Project project, String profileURI) Returns profile element by URIstatic Package
getProfileForStereotype
(Stereotype stereotype) Returns profile for a given stereotype.static Collection<Profile>
getProfiles
(Project project, String profileName) Filters all given project profiles by name.static Collection<Stereotype>
getSettableStereotypes
(Project project, String elementType, boolean includeSuperTypes) Returns collection of settable stereotypes for element typestatic Collection<Stereotype>
getSettableStereotypes
(Project project, Collection<? extends Element> elements, boolean includeSuperTypes) Returns collection of settable stereotypes for collection of elementsstatic Stereotype
getStereotype
(Project project, String stereotypeName, Profile profile) Returns stereotype for given name by profile.getStereotypedElements
(Stereotype stereotype) Returns all elements stereotyped by stereotypestatic Collection<Element>
getStereotypedElementsIncludingDerived
(Stereotype stereotype) Returns all elements stereotyped by stereotype and by stereotypes derived from this stereotype.static List<Stereotype>
getStereotypes
(Element element) Returns all stereotypes applied to element.static Set<Stereotype>
getStereotypesByMetaClasses
(Collection<Class> metaClasses) Collects stereotypes which extend given meta classes.static Collection<Stereotype>
getStereotypesByProfile
(Profile profile) Returns collection of stereotypes by profilegetTypeClasses
(Collection<? extends Element> elementTypes, boolean includeSubtypes, boolean expandAbstract) Converts Meta Class elements to java.lang.Class objects, stereotypes are left unchanged.static Collection<Object>
getTypeClasses
(Collection<Element> elementTypes) Converts Meta Class elements to java.lang.Class objects, stereotypes are left unchanged.static Class
getUML2BaseClass
(Element element) Returns UML2 metamodel metaclass for a given Element.static Class
getUML2BaseClassByJavaClass
(Project project, Class javaClass) Returns UML2 metamodel metaclass for a given Java class.static Class
getUML2MetaClassByName
(Project project, String name) /** Returns meta class from UML2 meta model by namestatic Collection<Class>
getUML2MetaClasses
(Project project) Returns collection of all UML2 meta classesstatic Model
getUML2MetaModel
(Project project) Returns model element for UML2 meta modelstatic boolean
hasStereotype
(Element element) Checks if element has applied stereotypesstatic boolean
hasStereotype
(Element element, Stereotype stereotype) Checks if element has applied stereotype.static boolean
hasStereotype
(Element element, Collection<Stereotype> stereotypes) Checks if element has applied at least one stereotype from given collection of Stereotypes.static boolean
hasStereotypedElements
(Stereotype stereotype) Checks if stereotype has stereotyped elementsstatic boolean
hasStereotypeOrDerived
(Element element, Stereotype stereotype) Checks if there are child of parent stereotype already setstatic boolean
hasStereotypeOrDerived
(Element element, Collection<Stereotype> stereotypes) Checks if element has applied at least one stereotype(or derived) from given collection of Stereotypes.static boolean
hasSuperMetaClass
(Stereotype stereotype, Class meta) Checks if stereotype has super meta class.static boolean
hasVisibleStereotype
(Element element) Check if given element has at least one visible stereotype.static boolean
isBuiltInUML2Metamodel
(Model model) Checks if given model is built in (not user modeled) UML metamodel.static boolean
isExtensionProperty
(Property property) static boolean
isFromPrimitiveTypes
(Element element) Checks if given element is from UML2 metamodel primitive types packagestatic boolean
isInvisible
(RedefinableElement element) Check is element is invisible (has Invisible stereotype or one of it's children)static boolean
isMetaClass
(Class aClass) Checks if Class is meta class, including user defined meta classes.static boolean
isMetaClass
(Element element) Checks if given element is a meta class, including user defined meta classes.static boolean
isOfType
(Element element, Collection<Class> metaTypes, boolean checkDSL) Checks if element is of type from given meta-typesstatic boolean
isRequiredStereotypeForElement
(Stereotype stereotype, Element element) Checks if stereotype is required for elementstatic boolean
isTypeOf
(Element element, Collection<Classifier> typesCollection, boolean includeInherited) Checks if element is of type from typesCollection.static boolean
isTypeOf
(Element element, Collection<Classifier> typesCollection, boolean includeInherited, boolean includeCustomTypes) Checks if element is of type from typesCollection.static boolean
isUML2MetaClass
(Class aClass) Checks if Class is meta class, and this meta class represents currently instantiated UML model.static void
optimizeStereotypes
(Element element) Optimize applied stereotypes to an Element by removing more general stereotypes if more specific are applied.static void
removeBaseClass
(Stereotype stereotype, Class metaClass) removes base (meta) class for stereotypestatic void
removeProfile
(Package pkg, Profile profile) Removes profile application from the packagestatic void
removeProfiles
(Package pkg, Collection<Profile> profiles) Removes applied profiles in package from collectionstatic void
removeStereotype
(Element element, Stereotype stereotype) Remove applied stereotype from element.static void
removeStereotypes
(Element element) Removes all applied stereotypes from element.static void
removeStereotypes
(Element element, Collection<Stereotype> stereotypes) Removes all stereotypes from element.static void
removeSuperMetaClasses
(Stereotype stereotype, Class meta) Remove super meta class from the given stereotype.static Extension
setBaseClass
(Stereotype stereotype, Class metaClass, Extension extension) Sets base (meta) class for stereotypestatic void
setBaseClasses
(Stereotype stereotype, Collection<Class> metaClasses) Sets base (meta) classes for stereotypestatic void
setBaseClassesByName
(Stereotype stereotype, Collection<String> metaClasses) Sets base (meta) classes for stereotype by namesMethods inherited from class com.nomagic.uml2.ext.jmi.helpers.TagsHelper
addTaggedValueValue, addTaggedValueValue, clearStereotypeProperty, clearStereotypeProperty, clearStereotypeProperty, clearStereotypeProperty, collectVisibleTaggedValues, createDefaultValues, createDefaultValues, getPropertiesWithDerived, getPropertiesWithDerivedOrdered, getPropertyByName, getStereotypePropertyFirst, getStereotypePropertyFirst, getStereotypePropertyFirst, getStereotypePropertyFirst, getStereotypePropertyStringValue, getStereotypePropertyValue, getStereotypePropertyValue, getStereotypePropertyValue, getStereotypePropertyValue, getStereotypePropertyValueAsString, getStereotypePropertyValueAsString, getTagDefinitionOwner, getTaggedValue, getTaggedValue, getTaggedValue, getTaggedValueOrCreate, getTaggedValueOrCreate, hasStereotypePropertyValues, isValidTagType, removeTaggedValueValue, removeTaggedValueValue, setStereotypePropertyValue, setStereotypePropertyValue, setStereotypePropertyValue, setStereotypePropertyValue, setStereotypePropertyValue, setStereotypePropertyValue, setStereotypePropertyValueWithClearPredicate
Methods inherited from class com.nomagic.uml2.ext.jmi.helpers.DeprecatedStereotypesHelper
addStereotypeByString, addStereotypeByString, addStereotypesWithNames, getExtendedElements, getExtendedElementsIncludingDerived, getStereotype, getStereotype, getStereotypePropertyValue, getStereotypePropertyValue, hasExtendedElements, hasStereotype, hasStereotype, hasStereotypeOrDerived, isElementStereotypedBy, removeStereotypeByString
Methods inherited from class com.nomagic.uml2.ext.jmi.helpers.DeprecatedTagsHelper
clearStereotypeProperty, clearStereotypeProperty, getStereotypePropertyFirst, getStereotypePropertyFirst, getStereotypePropertyValue, getStereotypePropertyValue, getStereotypePropertyValueAsString, getStereotypePropertyValueAsString
-
Field Details
-
UML2METAMODEL
Name of UML2 metamodel- See Also:
-
UML2METAMODEL_URI
URI of UML2 metamodel, must correspond UML standard profile metamodel uri.- See Also:
-
UML2METAMODEL_PRIMITIVE_TYPES
Name of primitives package in the UML2 metamodel- See Also:
-
-
Constructor Details
-
StereotypesHelper
public StereotypesHelper()
-
-
Method Details
-
getAllProfiles
Returns list of all loaded profiles. Returning writable copy.- Parameters:
project
- project- Returns:
- list of all loaded profiles
-
getProfile
Returns profile element by name- Parameters:
project
- projectprofileName
- profile name- Returns:
- profile element or null if profile not found
-
getProfileByURI
Returns profile element by URI- Parameters:
project
- projectprofileURI
- profile uri- Returns:
- profile element or null if profile not found
-
getProfiles
Filters all given project profiles by name.- Parameters:
project
- given projectprofileName
- the profile name- Returns:
- list of profiles that name corresponds to the given profile name
-
getStereotypes
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
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
- elementstereotype
- 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
- elementstereotypes
- 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 useTagsHelper.createDefaultValues(Element, Stereotype, boolean)
.- Parameters:
element
- elementstereotype
- 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 useTagsHelper.createDefaultValues(Element, Stereotype, boolean)
.- Parameters:
element
- elementstereotype
- stereotype to applyindex
- 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 useTagsHelper.createDefaultValues(Element, Stereotype, boolean)
.- Parameters:
element
- element on which stereotypes are appliedstereotypes
- collection ofStereotype
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
- elementstereotype
- stereotype to remove- Throws:
IllegalArgumentException
- if element or stereotype is null
-
removeStereotypes
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
- elementstereotypes
- 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
- elementstereotypeName
- 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
- projectstereotypeName
- name of stereotypeprofile
- 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
Returns all elements stereotyped by stereotype- Parameters:
stereotype
- stereotype- Returns:
- list of elements stereotyped by stereotype
-
hasStereotypedElements
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 stereotypesincludeInvisible
- indicates whether invisible stereotypes should be taken into account- Returns:
- first stereotype with icon
-
getFirstVisibleStereotype
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
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
Checks if stereotype has baseClass as METACLASS- Parameters:
stereotype
- stereotypebaseClass
- meta class- Returns:
- extension for base class
-
getExtensions
Collects Extensions connected to this stereotype.- Parameters:
stereotype
- StereotypebaseClass
- Base class.- Returns:
- List of extension.
-
getExtensions
public static Collection<Extension> getExtensions(Stereotype stereotype, Class baseClass, boolean takeInherited) Get Extension Meta Property.- Parameters:
stereotype
- StereotypebaseClass
- Base class.takeInherited
- collect inherited extension ends also- Returns:
- List of extension.
-
getBaseClasses
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
- stereotypeincludeFromParentStereotypes
- 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
- projectelementType
- element typeincludeSuperTypes
- 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
- projectelements
- collection of elementsincludeSuperTypes
- include super types also- Returns:
- collection of settable stereotypes
-
getUML2MetaModel
Returns model element for UML2 meta model- Parameters:
project
- project- Returns:
- model element for UML2 meta model
-
isBuiltInUML2Metamodel
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
Returns collection of all model elements- Parameters:
project
- project- Returns:
- collection of all model elements
-
getMetaModelByName
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
Returns collection of all meta model classes- Parameters:
project
- project- Returns:
- collection of all meta model classes
-
getUML2MetaClasses
Returns collection of all UML2 meta classes- Parameters:
project
- project- Returns:
- collection of all UML2 meta classes
-
getMetaClasses
Returns meta classes by collection of models- Parameters:
models
- collection of models- Returns:
- collection(Class) of meta classes
-
getNamesOfMetaClasses
Returns names of meta classes by collection of models- Parameters:
models
- collection of models- Returns:
- collection(String) of meta classes
-
getMetaClassByName
Returns meta class by name- Parameters:
project
- projectname
- name of meta class- Returns:
- Class element of meta class
-
getMetaClassByName
Returns meta class by name from collection of models- Parameters:
name
- name of meta classmodels
- collection of models to look for- Returns:
- Class element of meta class
-
getMetaClassesFromPackageByName
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
/** Returns meta class from UML2 meta model by name- Parameters:
project
- given projectname
- name of meta class- Returns:
- Class element of meta class
-
getMetaModelByMetaClass
Returns meta model of specified meta class.- Parameters:
metaClass
- meta class- Returns:
- meta model of meta class.
null
ifc
is not meta class
-
getMetaModelByElement
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
ifelement
is not meta class
-
isMetaClass
Checks if given element is a meta class, including user defined meta classes. For pure uml meta class useisUML2MetaClass(Class)
- Parameters:
element
- class- Returns:
- true if element is meta class
-
isMetaClass
Checks if Class is meta class, including user defined meta classes. For pure uml meta class useisUML2MetaClass(Class)
- Parameters:
aClass
- class- Returns:
- true if Class is meta class
-
isUML2MetaClass
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
Sets base (meta) classes for stereotype by names- Parameters:
stereotype
- stereotypemetaClasses
- collection of meta classes names
-
setBaseClasses
Sets base (meta) classes for stereotype- Parameters:
stereotype
- stereotypemetaClasses
- 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
- stereotypemetaClass
- meta classextension
- extension for class and stereotype- Returns:
- created Extension
-
removeBaseClass
removes base (meta) class for stereotype- Parameters:
stereotype
- stereotypemetaClass
- 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 stereotypename
- name of stereotypemetaClasses
- 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
- projectname
- name of stereotypemetaClasses
- meta classes for stereotype- Returns:
- created stereotype
-
getDefaultMetaClasses
Dummy procedure for setting of meta classes- Parameters:
project
- project- Returns:
- default meta class
-
getNamesOfSuperClasses
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
- elementstereotype
- stereotype- Returns:
- true if stereotype can be applied to element
-
getIcon
Returns ICON from stereotype- Parameters:
stereotype
- stereotype- Returns:
- icon
-
deriveStereotype
Derives stereotype from other stereotype.- Parameters:
parent
- parent stereotypechild
- child stereotype
-
getMetaClassByClass
Returns meta class by given class.- Parameters:
project
- projectclazz
- class from which to get name from- Returns:
- meta class
-
getMetaClassesByClass
Returns names of meta classes from collection- Parameters:
project
- projectclasses
- collection of meta classes to get names from- Returns:
- collection of names
-
getBaseClass
Returns meta class of given element.- Parameters:
element
- given element- Returns:
- Class element of meta class
-
getUML2BaseClass
Returns UML2 metamodel metaclass for a given Element.- Parameters:
element
- given element- Returns:
- Class element of meta class
-
getUML2BaseClassByJavaClass
Returns UML2 metamodel metaclass for a given Java class.- Parameters:
project
- projectjavaClass
- given Java Class- Returns:
- Class element of meta class
-
getBaseClassesAsClasses
Returns collection(java.lang.Class) of metaclasses from stereotype- Parameters:
stereotype
- stereotype- Returns:
- collection of meta classes
-
canAssignStereotype
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
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
Checks profile can apply to package.- Parameters:
pkg
- The given package.profile
- The given profile.- Returns:
- boolean
-
applyProfile
Applies profile to the package- Parameters:
pkg
- packageprofile
- profile to apply
-
removeProfile
Removes profile application from the package- Parameters:
pkg
- packageprofile
- applied profile
-
getStereotypesByProfile
Returns collection of stereotypes by profile- Parameters:
profile
- profile- Returns:
- collection of stereotypes by profile
-
isRequiredStereotypeForElement
Checks if stereotype is required for element- Parameters:
stereotype
- stereotypeelement
- element- Returns:
- true if stereotype is required for element
-
getClassOfMetaClass
Returns java.lang.Class for meta class by Class- Parameters:
metaClass
- meta class- Returns:
- java.lang.Class for meta class
-
applyProfiles
Applies profiles from collection to specified package- Parameters:
pkg
- packageprofiles
- list of profiles
-
removeProfiles
public static void removeProfiles(@CheckForNull Package pkg, @CheckForNull Collection<Profile> profiles) Removes applied profiles in package from collection- Parameters:
pkg
- packageprofiles
- collection of profiles
-
getAppliedProfiles
Returns collection of applied profiles on package- Parameters:
pkg
- package- Returns:
- collection of applied profiles
-
canRemoveProfile
Checks if it is possible to remove applied profile from package- Parameters:
pkg
- packageprofile
- profile- Returns:
- true if it is possible to remove applied profile
-
getDependingProfiles
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
- elementstereotype
- 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
- elementstereotypes
- 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 inparent
- 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
- elementparent
- stereotypeincludeParent
- true if include parent stereotype in collection- Returns:
- stereotype or child of stereotype for element
-
hasStereotypeOrDerived
Checks if there are child of parent stereotype already set- Parameters:
element
- elementstereotype
- 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 checkstereotypes
- a collection of stereotypes- Returns:
- true if element has applied at least one stereotype from given collection
- Throws:
IllegalArgumentException
- if element is null
-
getStereotypesByMetaClasses
Collects stereotypes which extend given meta classes.- Parameters:
metaClasses
- meta classes- Returns:
- stereotypes
-
getExtensionEnd
ExtensionEnd of given Extension- Parameters:
extension
- Extension- Returns:
- ExtensionEnd of Extension
-
assignImageFilesToStereotype
Assigns given image files to stereotype as icons.- Parameters:
stereotype
- stereotype to which icons should be appliedfiles
- image files to assign
-
getDerivedStereotypesRecursively
Returns derived stereotypes recursively- Parameters:
stereotype
- stereotype for which to return derived stereotypes- Returns:
- list of derived stereotypes
-
getElementsRequiresExtension
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
Collect all subtypes of given meta classes whose are extended by a given stereotype- Parameters:
stereotype
- stereotypemeta
- meta class- Returns:
- meta classes
-
hasSuperMetaClass
Checks if stereotype has super meta class.- Parameters:
stereotype
- stereotypemeta
- meta class- Returns:
- true if stereotype has super meta class.
-
removeSuperMetaClasses
Remove super meta class from the given stereotype.- Parameters:
stereotype
- stereotypemeta
- meta class
-
isExtensionProperty
- Parameters:
property
- property- Returns:
- true if given property is memberEnd of Extension
-
getProfileForStereotype
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
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 classesincludeInherited
- collection inherited meta properties- Returns:
- collection of properties.
-
isFromPrimitiveTypes
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
Returns primitive types package of UML2 metamodel.- Parameters:
project
- project.- Returns:
- primitive types package.
-
getPrimitiveByName
Finds primitiveType by name- Parameters:
project
- project where find primitive.name
- primitive name.- Returns:
- Primitive with given name.
-
hasVisibleStereotype
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
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 itincludeInherited
- 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 checkedtypesCollection
- collection of types used to check if element type is part of itincludeInherited
- if set to true all element type hierarchy will be checked against typesCollectionincludeCustomTypes
- check against custom types- Returns:
- true if element is of type from typesCollection
-
getTypeClasses
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 stereotypesincludeSubtypes
- 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
Checks if element is of type from given meta-types- Parameters:
element
- instance that type will be checkedmetaTypes
- meta typescheckDSL
- take DSL rules into account- Returns:
- true if element is of type from typesCollection
-