Package com.nomagic.magicdraw.uml2.util
Class UML2ModelUtil
- java.lang.Object
-
- com.nomagic.magicdraw.uml2.util.UML2ModelUtil
-
public class UML2ModelUtil extends java.lang.ObjectContains various UML2 model related utility methods.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringANNOTATION_SOURCE__MD_CONTAINMENTstatic java.lang.StringANNOTATION_SOURCE__MD_TRANSIENTstatic java.lang.StringANNOTATION_SOURCE__MOFstatic java.lang.StringANNOTATION_SOURCE__RENAMEDstatic java.lang.StringANNOTATION_SOURCE__SUBSETSstatic java.lang.StringANNOTATION_SOURCE__UNIONstatic java.lang.StringANNOTATION_SOURCE_REDEFINES
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckCompatibility(org.eclipse.emf.ecore.EObject object, org.eclipse.emf.ecore.EStructuralFeature structuralFeature, java.lang.Object value)Checks whether the specified object and specified feature value is valid.static voidcollectAllEClassifiers(org.eclipse.emf.ecore.EPackage ePackage, java.util.Collection<org.eclipse.emf.ecore.EClassifier> result)Collects all classifiers from the specified package recursively.static voidcollectEAllClasses(org.eclipse.emf.ecore.EPackage root, java.util.Collection<org.eclipse.emf.ecore.EClass> result)Collect all classifiers recursively into specified result collection.static java.util.Collection<org.eclipse.emf.ecore.EClassifier>getAllEClassifiers(org.eclipse.emf.ecore.EPackage aPackage)Returns all classifiers from the specified package recursively.static java.lang.StringgetChangePropertyName(org.eclipse.emf.ecore.EObject target, org.eclipse.emf.ecore.EStructuralFeature structuralFeature, java.lang.Object value)Returns change property name.static java.util.Collection<org.eclipse.emf.ecore.EClassifier>getCompatibleTypes(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EStructuralFeature feature)Returns Collection of EClassifiers which instances can be set as values to the specified feature to an instance of the type eClass.static java.lang.StringgetDefault(Property property)Returns string representation of the default value of the property.static org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EClass>getEAllSubClasses(org.eclipse.emf.ecore.EClass eClass)Returns all subclasses of the specified class.static org.eclipse.emf.ecore.EStructuralFeaturegetEStructuralFeature(org.eclipse.emf.ecore.EClass eClass, java.lang.String publicFeatureName)Returns structural feature from the specified class by public feature name.static java.lang.StringgetMOFPackageName(org.eclipse.emf.ecore.EClassifier classifier)Returns qualified MOF package name of the EClassifier that represents UML model element metaclass.static org.eclipse.emf.ecore.EStructuralFeaturegetOppositeRedefinition(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EStructuralFeature feature)Returns structural feature that redefines the specified feature.static java.lang.StringgetPrivateFeatureName(org.eclipse.emf.ecore.EClass containingClass, java.lang.String publicFeatureName)Returns private name of the specified feature.static java.lang.StringgetPublicFeatureName(org.eclipse.emf.ecore.EStructuralFeature feature)Returns public name of the structural feature.static java.util.List<java.lang.String>getQualifiedMOFPackageName(org.eclipse.emf.ecore.EClassifier classifier)Returns qualified MOF package name of the EClassifier that represents UML model element metaclass.static java.util.List<org.eclipse.emf.ecore.EStructuralFeature>getRedefinedFeatures(org.eclipse.emf.ecore.EStructuralFeature feature)Returns redefined features of the specified feature.static org.eclipse.emf.ecore.EStructuralFeaturegetRedefinition(org.eclipse.emf.ecore.EClass eContainingClass, org.eclipse.emf.ecore.EStructuralFeature feature)Returns structural feature that redefines the specified feature.static java.util.List<org.eclipse.emf.ecore.EStructuralFeature>getSortedFeatures(org.eclipse.emf.ecore.EClass eClass)Returns sorted features.static java.util.List<org.eclipse.emf.ecore.EReference>getSortedReferences(org.eclipse.emf.ecore.EClass eClass)Returns sorted reference.static java.util.List<org.eclipse.emf.ecore.EStructuralFeature>getSubsetFeatures(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EStructuralFeature supersetFeature, boolean includeDerived, boolean includeMany)Returns subset features of the specified superset feature.static java.util.List<org.eclipse.emf.ecore.EStructuralFeature>getSubsettedFeatures(org.eclipse.emf.ecore.EStructuralFeature eStructuralFeature)Returns subsetted feature list of the specified feature.static java.util.List<org.eclipse.emf.ecore.EStructuralFeature>getSubsettedFeatures(org.eclipse.emf.ecore.EStructuralFeature eStructuralFeature, boolean recursive)Returns subsetted feature list of the specified feature.static booleanisAssignableFrom(org.eclipse.emf.ecore.EClassifier a, org.eclipse.emf.ecore.EClassifier b)Determines if the instance class represented by the first EClassifier object is either the same as, or is a superclass of the instance class represented by the specified second EClassifier parameter.static booleanisCheckCompatibility()static booleanisCompatible(org.eclipse.emf.ecore.EObject obj, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value)Checks whether the specified object and specified feature value is valid.static booleanisContainer(org.eclipse.emf.ecore.EReference reference)Returns true if the reference should be treated as container reference.static booleanisContainment(org.eclipse.emf.ecore.EReference reference)Returns true if the reference should be treated as containment reference.static booleanisDerivedButNotUnion(org.eclipse.emf.ecore.EStructuralFeature feature)Returns true if the specified feature is derived but not derived union.static booleanisDerivedUnion(org.eclipse.emf.ecore.EStructuralFeature feature)Checks whether the specified feature is derived union.static booleanisFullyCompatible(org.eclipse.emf.ecore.EObject obj, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value)Returns whether the specified object feature can be set to/value added to collection representing value of the feature or can not.static booleanisMDMultiplicityMany(org.eclipse.emf.ecore.EStructuralFeature feature)Returns true if the multiplicity of the property should be treated as many.static booleanisMDTransient(org.eclipse.emf.ecore.EStructuralFeature feature)Returns true if the feature is marked transient in MD.static booleanisOppositeRedefined(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EStructuralFeature feature)Returns whether the specified feature is redefined.static booleanisRedefined(org.eclipse.emf.ecore.EClass eContainingClass, org.eclipse.emf.ecore.EStructuralFeature feature)Returns whether the specified feature is redefined.static booleanisRedefinition(org.eclipse.emf.ecore.EStructuralFeature feature)Returns true if the specified feature is redefinition of another feature.static booleanisRenamed(org.eclipse.emf.ecore.EStructuralFeature feature)Returns true if the specified feature is renamed.static booleanisSubsets(org.eclipse.emf.ecore.EReference reference)static booleanisSuperset(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EStructuralFeature eStructuralFeature)Returns true if the specified structural feature in the specified EClass is superset.static booleanisTransient(org.eclipse.emf.ecore.EStructuralFeature feature)Returns true if the feature is transient or marked transient in MD.static voidsetCheckCompatibility(boolean checkCompatibility)
-
-
-
Field Detail
-
ANNOTATION_SOURCE__UNION
public static final java.lang.String ANNOTATION_SOURCE__UNION
- See Also:
- Constant Field Values
-
ANNOTATION_SOURCE__SUBSETS
public static final java.lang.String ANNOTATION_SOURCE__SUBSETS
- See Also:
- Constant Field Values
-
ANNOTATION_SOURCE_REDEFINES
public static final java.lang.String ANNOTATION_SOURCE_REDEFINES
- See Also:
- Constant Field Values
-
ANNOTATION_SOURCE__MD_TRANSIENT
public static final java.lang.String ANNOTATION_SOURCE__MD_TRANSIENT
- See Also:
- Constant Field Values
-
ANNOTATION_SOURCE__MOF
public static final java.lang.String ANNOTATION_SOURCE__MOF
- See Also:
- Constant Field Values
-
ANNOTATION_SOURCE__RENAMED
public static final java.lang.String ANNOTATION_SOURCE__RENAMED
- See Also:
- Constant Field Values
-
ANNOTATION_SOURCE__MD_CONTAINMENT
public static final java.lang.String ANNOTATION_SOURCE__MD_CONTAINMENT
- See Also:
- Constant Field Values
-
-
Method Detail
-
isCheckCompatibility
public static boolean isCheckCompatibility()
-
setCheckCompatibility
public static void setCheckCompatibility(boolean checkCompatibility)
-
isDerivedUnion
public static boolean isDerivedUnion(org.eclipse.emf.ecore.EStructuralFeature feature)
Checks whether the specified feature is derived union.- Parameters:
feature- a feature.- Returns:
- true if it is derived union.
-
isSubsets
public static boolean isSubsets(org.eclipse.emf.ecore.EReference reference)
-
getSubsettedFeatures
public static java.util.List<org.eclipse.emf.ecore.EStructuralFeature> getSubsettedFeatures(org.eclipse.emf.ecore.EStructuralFeature eStructuralFeature)
Returns subsetted feature list of the specified feature. Returns empty list if the features has no subsetted features.- Parameters:
eStructuralFeature- feature which subsetted features should be returned.- Returns:
- list of subsetted features.
-
getSubsettedFeatures
public static java.util.List<org.eclipse.emf.ecore.EStructuralFeature> getSubsettedFeatures(org.eclipse.emf.ecore.EStructuralFeature eStructuralFeature, boolean recursive)Returns subsetted feature list of the specified feature. Returns empty list if the features has no subsetted features.- Parameters:
eStructuralFeature- feature which subsetted features should be returned.recursive- if true then search for subsetted features recursively.- Returns:
- list of subsetted features.
-
getSubsetFeatures
public static java.util.List<org.eclipse.emf.ecore.EStructuralFeature> getSubsetFeatures(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EStructuralFeature supersetFeature, boolean includeDerived, boolean includeMany)Returns subset features of the specified superset feature.- Parameters:
eClass- EClass that is a context of search.supersetFeature- superset feature.includeDerived- if value is true then derived properties should be included into result.includeMany- if true then multivalue features should be included into result.- Returns:
- list of subset features.
-
isSuperset
public static boolean isSuperset(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EStructuralFeature eStructuralFeature)Returns true if the specified structural feature in the specified EClass is superset.- Parameters:
eClass- EClass object which features will be analysed.eStructuralFeature- structural feature.- Returns:
- true if it is superset.
-
isRedefinition
public static boolean isRedefinition(org.eclipse.emf.ecore.EStructuralFeature feature)
Returns true if the specified feature is redefinition of another feature.- Parameters:
feature- a feature.- Returns:
- true if redefinition.
-
isMDTransient
public static boolean isMDTransient(org.eclipse.emf.ecore.EStructuralFeature feature)
Returns true if the feature is marked transient in MD. This method does not fully replace isPrivatePropertyName, useisTransient(EStructuralFeature)for this.- Parameters:
feature- structural feature.- Returns:
- true if md transient.
-
isTransient
public static boolean isTransient(org.eclipse.emf.ecore.EStructuralFeature feature)
Returns true if the feature is transient or marked transient in MD.- Parameters:
feature- structural feature.- Returns:
- true if transient or md transient.
-
getMOFPackageName
@CheckForNull public static java.lang.String getMOFPackageName(org.eclipse.emf.ecore.EClassifier classifier)
Returns qualified MOF package name of the EClassifier that represents UML model element metaclass. Separator used in the qualified name is '.'- Parameters:
classifier- classifier from UML metamodel.- Returns:
- package name or null if the classifier is not from UML metamodel.
- Throws:
java.lang.IllegalArgumentException- if the classifier parameter is null.
-
getQualifiedMOFPackageName
@CheckForNull public static java.util.List<java.lang.String> getQualifiedMOFPackageName(org.eclipse.emf.ecore.EClassifier classifier)
Returns qualified MOF package name of the EClassifier that represents UML model element metaclass.- Parameters:
classifier- classifier from UML metamodel.- Returns:
- list of MOF package names null if the classifier is not from UML metamodel.
- Throws:
java.lang.IllegalArgumentException- if the classifier parameter is null.
-
collectEAllClasses
public static void collectEAllClasses(org.eclipse.emf.ecore.EPackage root, java.util.Collection<org.eclipse.emf.ecore.EClass> result)Collect all classifiers recursively into specified result collection.- Parameters:
root- root EPackage.result- result collection.
-
getRedefinedFeatures
public static java.util.List<org.eclipse.emf.ecore.EStructuralFeature> getRedefinedFeatures(org.eclipse.emf.ecore.EStructuralFeature feature)
Returns redefined features of the specified feature.- Parameters:
feature- a structural feature.- Returns:
- redefined features.
-
getRedefinition
@CheckForNull public static org.eclipse.emf.ecore.EStructuralFeature getRedefinition(org.eclipse.emf.ecore.EClass eContainingClass, org.eclipse.emf.ecore.EStructuralFeature feature)Returns structural feature that redefines the specified feature. Uses map for fast search.- Parameters:
eContainingClass- containing EClass.feature- structural feature that mey be redefined.- Returns:
- redefinition feature or null if the specified feature is not redefined.
-
getOppositeRedefinition
@CheckForNull public static org.eclipse.emf.ecore.EStructuralFeature getOppositeRedefinition(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EStructuralFeature feature)Returns structural feature that redefines the specified feature.- Parameters:
eClass- containing EClass.feature- structural feature that mey be redefined.- Returns:
- redefinition feature or null if the specified feature is not redefined.
-
isRedefined
public static boolean isRedefined(org.eclipse.emf.ecore.EClass eContainingClass, org.eclipse.emf.ecore.EStructuralFeature feature)Returns whether the specified feature is redefined.- Parameters:
eContainingClass- containing EClass.feature- structural feature that mey be redefined.- Returns:
- true if redefined.
-
isOppositeRedefined
public static boolean isOppositeRedefined(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EStructuralFeature feature)Returns whether the specified feature is redefined.- Parameters:
eClass- containing EClass.feature- structural feature that mey be redefined.- Returns:
- true if redefined.
-
isFullyCompatible
public static boolean isFullyCompatible(org.eclipse.emf.ecore.EObject obj, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value)Returns whether the specified object feature can be set to/value added to collection representing value of the feature or can not.- Parameters:
obj- an object which feature should be analysed.feature- a feature that should be analysed.value- a value of the feature.- Returns:
- true if value can be set.
-
isCompatible
public static boolean isCompatible(org.eclipse.emf.ecore.EObject obj, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value)Checks whether the specified object and specified feature value is valid.- Parameters:
obj- an object.feature- a feature that should be checked.value- value that should be checked.- Returns:
- true if compatible.
-
checkCompatibility
public static void checkCompatibility(org.eclipse.emf.ecore.EObject object, org.eclipse.emf.ecore.EStructuralFeature structuralFeature, java.lang.Object value)Checks whether the specified object and specified feature value is valid.- Parameters:
object- an object.structuralFeature- a structural feature.value- a value.- Throws:
java.lang.IllegalArgumentException- if the specified value is not compatible.
-
isRenamed
public static boolean isRenamed(org.eclipse.emf.ecore.EStructuralFeature feature)
Returns true if the specified feature is renamed.- Parameters:
feature- a feature.- Returns:
- renamed.
-
getPublicFeatureName
public static java.lang.String getPublicFeatureName(org.eclipse.emf.ecore.EStructuralFeature feature)
Returns public name of the structural feature.- Parameters:
feature- a structural feature.- Returns:
- public name.
-
getPrivateFeatureName
public static java.lang.String getPrivateFeatureName(org.eclipse.emf.ecore.EClass containingClass, java.lang.String publicFeatureName)Returns private name of the specified feature.- Parameters:
containingClass- a class that private feature name should be returned.publicFeatureName- public name of the feature.- Returns:
- private name of the feature.
-
getChangePropertyName
public static java.lang.String getChangePropertyName(org.eclipse.emf.ecore.EObject target, org.eclipse.emf.ecore.EStructuralFeature structuralFeature, java.lang.Object value)Returns change property name.- Parameters:
target- owner of the property.structuralFeature- feature changed.value- value of the property.- Returns:
- name of the property change.
-
getEStructuralFeature
public static org.eclipse.emf.ecore.EStructuralFeature getEStructuralFeature(org.eclipse.emf.ecore.EClass eClass, java.lang.String publicFeatureName)Returns structural feature from the specified class by public feature name.- Parameters:
eClass- EClass.publicFeatureName- public feature name.- Returns:
- structural feature or null if no such exist.
-
isContainment
public static boolean isContainment(org.eclipse.emf.ecore.EReference reference)
Returns true if the reference should be treated as containment reference.- Parameters:
reference- a reference.- Returns:
- true if it is containment reference.
-
isContainer
public static boolean isContainer(org.eclipse.emf.ecore.EReference reference)
Returns true if the reference should be treated as container reference.- Parameters:
reference- a reference.- Returns:
- true if it is container reference.
-
getSortedReferences
public static java.util.List<org.eclipse.emf.ecore.EReference> getSortedReferences(org.eclipse.emf.ecore.EClass eClass)
Returns sorted reference. References are sorted in the order that allows correct sequential modification of reference values.- Parameters:
eClass- EClass object.- Returns:
- references where supersets are in the latest positions.
-
getSortedFeatures
public static java.util.List<org.eclipse.emf.ecore.EStructuralFeature> getSortedFeatures(org.eclipse.emf.ecore.EClass eClass)
Returns sorted features. Features are sorted in the order that allows correct sequential modification of feature values.- Parameters:
eClass- EClass instance.- Returns:
- sorted features.
-
isDerivedButNotUnion
public static boolean isDerivedButNotUnion(org.eclipse.emf.ecore.EStructuralFeature feature)
Returns true if the specified feature is derived but not derived union.- Parameters:
feature- a structural feature.- Returns:
- true if the feature is derived but not derived union.
-
getEAllSubClasses
public static org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EClass> getEAllSubClasses(org.eclipse.emf.ecore.EClass eClass)
Returns all subclasses of the specified class. The method returns subclasses from the package to which belongs the specified class. If there are other packages that contains classes that extends the specified class then these classes will not be returned. The method return only not abstract classes.- Parameters:
eClass- a class which subclasses must be returned.- Returns:
- list of subclasses.
-
collectAllEClassifiers
public static void collectAllEClassifiers(org.eclipse.emf.ecore.EPackage ePackage, java.util.Collection<org.eclipse.emf.ecore.EClassifier> result)Collects all classifiers from the specified package recursively.- Parameters:
ePackage- a package from which to collect classifiers.result- result collection.
-
getAllEClassifiers
public static java.util.Collection<org.eclipse.emf.ecore.EClassifier> getAllEClassifiers(org.eclipse.emf.ecore.EPackage aPackage)
Returns all classifiers from the specified package recursively.- Parameters:
aPackage- a package.- Returns:
- result collection.
-
isAssignableFrom
public static boolean isAssignableFrom(org.eclipse.emf.ecore.EClassifier a, org.eclipse.emf.ecore.EClassifier b)Determines if the instance class represented by the first EClassifier object is either the same as, or is a superclass of the instance class represented by the specified second EClassifier parameter.- Parameters:
a- first classifier.b- second classifier.- Returns:
- true if assignable.
-
getCompatibleTypes
public static java.util.Collection<org.eclipse.emf.ecore.EClassifier> getCompatibleTypes(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EStructuralFeature feature)Returns Collection of EClassifiers which instances can be set as values to the specified feature to an instance of the type eClass.- Parameters:
eClass- EClass object which reference should be analyzed.feature- a structural feature which should be analyzed.- Returns:
- compatible type.
- Throws:
java.lang.IllegalArgumentException- if the specified EClass is not from UML package or if the specified feature is not contained by the class.
-
getDefault
public static java.lang.String getDefault(Property property)
Returns string representation of the default value of the property.- Parameters:
property- a property.- Returns:
- default value as string.
-
isMDMultiplicityMany
public static boolean isMDMultiplicityMany(org.eclipse.emf.ecore.EStructuralFeature feature)
Returns true if the multiplicity of the property should be treated as many. Otherwise - false.- Parameters:
feature- a structural feature.- Returns:
- true if many otherwise - false.
-
-