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
FieldsModifier and TypeFieldDescriptionstatic final StringName of UML2 metamodelstatic final StringName of primitives package in the UML2 metamodelstatic final StringURI 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddStereotype(Element element, Stereotype stereotype) Applies stereotype to a given element.static voidaddStereotype(Element element, Stereotype stereotype, int index) Applies stereotype to a given element.static voidaddStereotypes(Element element, Collection<Stereotype> stereotypes) Applies stereotypes from collection for specified element.static voidapplyProfile(Package pkg, Profile profile) Applies profile to the packagestatic voidapplyProfiles(Package pkg, Collection<Profile> profiles) Applies profiles from collection to specified packagestatic voidassignImageFilesToStereotype(Stereotype stereotype, Collection<File> files) Assigns given image files to stereotype as icons.static booleancanApplyProfile(Package pkg, Profile profile) Checks profile can apply to package.static booleancanApplyStereotype(Element element, Stereotype stereotype) Checks if stereotype can be applied to elementstatic booleancanAssignStereotype(Element element, Stereotype stereotype) Indicates if stereotype can be applied to a given element.static booleancanRemoveProfile(Package pkg, Profile profile) Checks if it is possible to remove applied profile from packagestatic StereotypecheckForDerivedStereotype(Element element, Stereotype stereotype) Checks if the given stereotype, or it's child is already applied to the element.static StereotypecheckForDerivedStereotype(Element element, Collection<Stereotype> stereotypes) Checks if there are child of at least one given stereotype already set to given elementstatic StereotypecheckForDerivedStereotype(Collection<Stereotype> stereotypes, Stereotype parent) Checks if there are given stereotype or derived stereotype in a given stereotypes collection.static StereotypecreateStereotype(Project project, String name, Collection<Class> metaClasses) Creates stereotype instance and sets base classes for itstatic StereotypecreateStereotype(Element owner, String name, Collection<Class> metaClasses) Creates stereotype instance and sets base classes for itstatic voidderiveStereotype(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 metamodel 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 StereotypegetAppliedStereotypeByString(Element element, String stereotypeName) Returns stereotype applied to element with given name.getAssignedMetaClassOfSubtype(Stereotype stereotype, Class meta) Collect all subtypes of given metaclasses whose are extended by a given stereotypestatic ClassgetBaseClass(Element element) Returns metaclass 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 ClassgetClassOfMetaClass(Class metaClass) Returns java.lang.Class for metaclass by Classstatic Collection<Class>getDefaultMetaClasses(Project project) Dummy procedure for setting of metaclassesstatic Collection<Profile>getDependingProfiles(Profile profile) Returns collection of profiles depending on given 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 ExtensiongetExtension(Stereotype stereotype, Class baseClass) Checks if stereotype has baseClass as METACLASSstatic ExtensionEndgetExtensionEnd(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 StereotypegetFirstStereotypeWithIcon(Collection<? extends Stereotype> collectionOfStereotypes) Returns first stereotype with icon from given collection of stereotypes.static StereotypegetFirstStereotypeWithIcon(Collection<? extends Stereotype> collectionOfStereotypes, boolean includeInvisible) Returns first stereotype with icon from given collection of stereotypes.static StereotypegetFirstVisibleStereotype(Element element) Returns first visible stereotype applied to given element.static StereotypegetFirstVisibleStereotype(Collection<? extends Stereotype> stereotypes) Returns first visible stereotype from given collection of stereotypes.static ResizableIcongetIcon(Stereotype stereotype) Returns ICON from stereotypestatic ClassgetMetaClassByClass(Project project, Class clazz) Returns metaclass by given class.static ClassgetMetaClassByName(Project project, String name) Returns metaclass by namestatic ClassgetMetaClassByName(String name, Collection<Model> models) Returns metaclass by name from collection of modelsstatic Collection<Class>getMetaClasses(Collection<? extends Model> models) Returns metaclasses by collection of modelsgetMetaClassesByClass(Project project, Collection<Class> classes) Returns names of metaclasses from collectionstatic ClassgetMetaClassesFromPackageByName(Package pkg, String name) Search for class in given scope(package) by class name.static ModelgetMetaModelByElement(Element element) Returns metamodel of specified element in the metamodel.static ModelgetMetaModelByMetaClass(Class metaClass) Returns meta model of specified meta class.static ModelgetMetaModelByName(Project project, String name) Return metamodel with specified name.static Collection<String>getNamesOfMetaClasses(Collection<? extends Model> models) Returns names of metaclasses by collection of modelsstatic Collection<String>getNamesOfSuperClasses(Class aClass) Returns names of supper classes for metaclassstatic PrimitiveTypegetPrimitiveByName(Project project, String name) Finds primitiveType by namestatic PackagegetPrimitiveTypesPackage(Project project) Returns primitive types package of UML2 metamodel.static ProfilegetProfile(Project project, String profileName) Returns profile element by namestatic ProfilegetProfileByURI(Project project, String profileURI) Returns profile element by URIstatic PackagegetProfileForStereotype(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 StereotypegetStereotype(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 metaclasses.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 ClassgetUML2BaseClass(Element element) Returns UML2 metamodel metaclass for a given Element.static ClassgetUML2BaseClassByJavaClass(Project project, Class javaClass) Returns UML2 metamodel metaclass for a given Java class.static ClassgetUML2MetaClassByName(Project project, String name) /** Returns meta class from UML2 meta model by namestatic Collection<Class>getUML2MetaClasses(Project project) Returns collection of all UML2 metaclassesstatic ModelgetUML2MetaModel(Project project) Returns model element for UML2 meta modelstatic booleanhasStereotype(Element element) Checks if element has applied stereotypesstatic booleanhasStereotype(Element element, Stereotype stereotype) Checks if element has applied stereotype.static booleanhasStereotype(Element element, Collection<Stereotype> stereotypes) Checks if element has applied at least one stereotype from given collection of Stereotypes.static booleanhasStereotypedElements(Stereotype stereotype) Checks if stereotype has stereotyped elementsstatic booleanhasStereotypeOrDerived(Element element, Stereotype stereotype) Checks if there are child of parent stereotype already setstatic booleanhasStereotypeOrDerived(Element element, Collection<Stereotype> stereotypes) Checks if element has applied at least one stereotype(or derived) from given collection of Stereotypes.static booleanhasSuperMetaClass(Stereotype stereotype, Class meta) Checks if stereotype has super metaclass.static booleanhasVisibleStereotype(Element element) Check if given element has at least one visible stereotype.static booleanisBuiltInUML2Metamodel(Model model) Checks if given model is built in (not user modeled) UML metamodel.static booleanisExtensionProperty(Property property) static booleanisFromPrimitiveTypes(Element element) Checks if given element is from UML2 metamodel primitive types packagestatic booleanisInvisible(RedefinableElement element) Check is element is invisible (has Invisible stereotype or one of its children)static booleanisMetaClass(Class aClass) Checks if Class is metaclass, including user defined metaclasses.static booleanisMetaClass(Element element) Checks if given element is a metaclass, including user defined metaclasses.static booleanisOfType(Element element, Collection<Class> metaTypes, boolean checkDSL) Checks if element is of type from given meta-typesstatic booleanisRequiredStereotypeForElement(Stereotype stereotype, Element element) Checks if stereotype is required for elementstatic booleanisTypeOf(Element element, Collection<Classifier> typesCollection, boolean includeInherited) Checks if element is of type from typesCollection.static booleanisTypeOf(Element element, Collection<Classifier> typesCollection, boolean includeInherited, boolean includeCustomTypes) Checks if element is of type from typesCollection.static booleanisUML2MetaClass(Class aClass) Checks if Class is metaclass, and this metaclass represents currently instantiated UML model.static voidoptimizeStereotypes(Element element) Optimize applied stereotypes to an Element by removing more general stereotypes if more specific are applied.static voidremoveBaseClass(Stereotype stereotype, Class metaClass) removes base (meta) class for stereotypestatic voidremoveProfile(Package pkg, Profile profile) Removes profile application from the packagestatic voidremoveProfiles(Package pkg, Collection<Profile> profiles) Removes applied profiles in package from collectionstatic voidremoveStereotype(Element element, Stereotype stereotype) Remove applied stereotype from element.static voidremoveStereotypes(Element element) Removes all applied stereotypes from element.static voidremoveStereotypes(Element element, Collection<Stereotype> stereotypes) Removes all stereotypes from element.static voidremoveSuperMetaClasses(Stereotype stereotype, Class meta) Remove super metaclass from the given stereotype.static ExtensionsetBaseClass(Stereotype stereotype, Class metaClass, Extension extension) Sets base (meta) class for stereotypestatic voidsetBaseClasses(Stereotype stereotype, Collection<Class> metaClasses) Sets base (meta) classes for stereotypestatic voidsetBaseClassesByName(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, setStereotypePropertyValueWithClearPredicateMethods inherited from class com.nomagic.uml2.ext.jmi.helpers.DeprecatedStereotypesHelper
addStereotypeByString, addStereotypeByString, addStereotypesWithNames, getExtendedElements, getExtendedElementsIncludingDerived, getStereotype, getStereotype, getStereotypePropertyValue, getStereotypePropertyValue, hasExtendedElements, hasStereotype, hasStereotype, hasStereotypeOrDerived, isElementStereotypedBy, removeStereotypeByStringMethods 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 it 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 ofStereotypeobjects- 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 metamodel with specified name.- Parameters:
project- project to search for metamodel.name- name metamodel name.- Returns:
- metamodel with specified name.
nullif not found.
-
getAllMetaClasses
Returns collection of all metamodel classes- Parameters:
project- project- Returns:
- collection of all meta model classes
-
getUML2MetaClasses
Returns collection of all UML2 metaclasses- Parameters:
project- project- Returns:
- collection of all UML2 metaclasses
-
getMetaClasses
Returns metaclasses by collection of models- Parameters:
models- collection of models- Returns:
- collection(Class) of meta classes
-
getNamesOfMetaClasses
Returns names of metaclasses by collection of models- Parameters:
models- collection of models- Returns:
- collection(String) of metaclasses
-
getMetaClassByName
Returns metaclass by name- Parameters:
project- projectname- name of metaclass- Returns:
- Class element of metaclass
-
getMetaClassByName
Returns metaclass by name from collection of models- Parameters:
name- name of metaclassmodels- collection of models to look for- Returns:
- Class element of metaclass
-
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 metaclass- Returns:
- Class element of metaclass
-
getMetaModelByMetaClass
Returns meta model of specified meta class.- Parameters:
metaClass- meta class- Returns:
- metamodel of metaclass.
nullifcis not metaclass
-
getMetaModelByElement
Returns metamodel of specified element in the metamodel. Method is expanded to support enumerations and literals from model.- Parameters:
element- metaclass or other meta element.- Returns:
- metamodel of metaclass.
nullifelementis not metaclass
-
isMetaClass
Checks if given element is a metaclass, including user defined metaclasses. For pure uml metaclass useisUML2MetaClass(Class)- Parameters:
element- class- Returns:
- true if element is metaclass
-
isMetaClass
Checks if Class is metaclass, including user defined metaclasses. For pure uml metaclass useisUML2MetaClass(Class)- Parameters:
aClass- class- Returns:
- true if Class is metaclass
-
isUML2MetaClass
Checks if Class is metaclass, and this metaclass represents currently instantiated UML model.- Parameters:
aClass- class- Returns:
- true if Class is uml 2 metaclass.
-
setBaseClassesByName
Sets base (meta) classes for stereotype by names- Parameters:
stereotype- stereotypemetaClasses- collection of metaclasses names
-
setBaseClasses
Sets base (meta) classes for stereotype- Parameters:
stereotype- stereotypemetaClasses- collection of metaclasses
-
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 metaclasses- Parameters:
project- project- Returns:
- default meta class
-
getNamesOfSuperClasses
Returns names of supper classes for metaclass- 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 metaclass by given class.- Parameters:
project- projectclazz- class from which to get name from- Returns:
- meta class
-
getMetaClassesByClass
Returns names of metaclasses from collection- Parameters:
project- projectclasses- collection of metaclasses to get names from- Returns:
- collection of names
-
getBaseClass
Returns metaclass of given element.- Parameters:
element- given element- Returns:
- Class element of metaclass
-
getUML2BaseClass
Returns UML2 metamodel metaclass for a given Element.- Parameters:
element- given element- Returns:
- Class element of metaclass
-
getUML2BaseClassByJavaClass
Returns UML2 metamodel metaclass for a given Java class.- Parameters:
project- projectjavaClass- given Java Class- Returns:
- Class element of metaclass
-
getBaseClassesAsClasses
Returns collection(java.lang.Class) of metaclasses from stereotype- Parameters:
stereotype- stereotype- Returns:
- collection of metaclasses
-
canAssignStereotype
Indicates if stereotype can be applied to a given element.- checks if stereotype metaclass fits class of an element.
- Parameters:
element- element to which stereotype should be applied.stereotype- stereotype to assign.- Returns:
- true if stereotype can be applied, false otherwise.
-
isInvisible
Check is element is invisible (has Invisible stereotype or one of its 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 metaclass by Class- Parameters:
metaClass- meta class- Returns:
- java.lang.Class for metaclass
-
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 profiles depending on given profile- Parameters:
profile- profile- Returns:
- collection of profiles
-
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 metaclasses.- 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 metaclasses whose are extended by a given stereotype- Parameters:
stereotype- stereotypemeta- meta class- Returns:
- meta classes
-
hasSuperMetaClass
Checks if stereotype has super metaclass.- Parameters:
stereotype- stereotypemeta- meta class- Returns:
- true if stereotype has super metaclass.
-
removeSuperMetaClasses
Remove super metaclass 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 metaclasses- 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 metaclassesincludeInherited- 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
-