Package com.nomagic.magicdraw.uml2
Class Classifiers
java.lang.Object
com.nomagic.magicdraw.uml2.Classifiers
Convenience utility methods that operate on or return
Classifier
elements.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Classifier>
voidcollectDerivedClassifiers
(Classifier general, Collection<T> result) Collect all derived classifiers recursively (not only the direct children).static <T extends Classifier>
voidcollectGeneralClassifiersRecursively
(Classifier specific, Collection<T> result) Collects all general classifiers including the indirect ones up to the hierarchy top.static Collection<Classifier>
collectGeneralClassifiersRecursively
(Collection<? extends Classifier> classifiers) Returns all general classifiers including the indirect ones up to hierarchy top.static void
collectInheritedEnumerationLiterals
(Enumeration enumeration, Collection<EnumerationLiteral> result, boolean collectOwned, boolean collectPrivate) Collect inherited and owned literals from the given enumeration.static void
collectInheritedRealizedInterfaces
(BehavioredClassifier classifier, Collection<Interface> result, boolean collectOwned) Collect inherited and directly realized interfaces from the given classifierstatic List<InterfaceRealization>
collectInterfaceRealizations
(BehavioredClassifier classifier, Interface contract) Collects interface realizations for the given contractstatic void
collectRealizedInterfacesRecursively
(Collection<? extends Classifier> classifiers, Collection<Interface> result) Collects all realized interfaces by the given classifiers and their general classifiers recursively.static List<EnumerationLiteral>
getAllLiterals
(Enumeration enumeration) Return owned and inherited enumeration literalsstatic Classifier
getClassifierOrDerived
(Collection<? extends Classifier> classifiers, Classifier checkFor) Checks if classifier collection contains given classifier or any derived from it, and returns the first foundstatic Collection<Classifier>
getDerivedClassifiers
(Classifier general) Get all derived classifiers for given classifier recursively.static Collection<Classifier>
getDirectDerivedClassifiers
(Classifier general) Return classifiers derived directly from the given classifierstatic Collection<Classifier>
getDirectGeneralClassifiers
(Classifier classifier) Returns general classifiers from which the given classifier is directly derived.static Collection<Classifier>
getGeneralClassifiersRecursively
(Classifier specific) Returns all general classifiers including the indirect ones up to the hierarchy top.getPropertiesWithoutRedefined
(Classifier classifier) Gets owned and inherited properties without redefined ones.getRealizedInterfaces
(BehavioredClassifier classifier) Collects all realized interfaces by the given classifier directly.static Property
getSameOrRedefined
(Classifier classifier, Property property) Resolves given property to itself or property redefined in the given classifier.static boolean
isClassifierOfType
(Collection<? extends Classifier> classifiers, Classifier type) Tests if there is at least one classifier among given ones which isTypeOf (equals or is derived) given type.static boolean
isDerivedClassifier
(Classifier parent, Classifier child) Checks if given classifier "child" is derived from "parent".static boolean
isDerivedOrRealizes
(Classifier classifier, Classifier type) Checks if classifier is derived from given type or realizes the given type.static boolean
isSameOrDerivedClassifier
(Classifier parent, Classifier child) Checks if given classifier "child" is same as "parent" or is derived from "parent".static boolean
isSameOrRedefined
(Property first, Property second) Check if given first property is the same as second property or first property is redefined by second propertystatic boolean
isSecondTypeCompatibleToFirst
(Type firstType, Type secondType, boolean checkRealizedInterfaces) Indicates if second parameter type is compatible to the first (is same type or a subtype).static void
removeRedefined
(Collection<? extends RedefinableElement> major, Collection<? extends RedefinableElement>... additional) Removes redefined elements from a given major collection.
-
Constructor Details
-
Classifiers
public Classifiers()
-
-
Method Details
-
getDerivedClassifiers
Get all derived classifiers for given classifier recursively. Result does not include given classifier.- Parameters:
general
- given classifier to collect specific classifiers for- Returns:
- collection of all derived classifiers
-
collectDerivedClassifiers
public static <T extends Classifier> void collectDerivedClassifiers(Classifier general, Collection<T> result) Collect all derived classifiers recursively (not only the direct children).- Parameters:
general
- general classifierresult
- collection of all derived classifiers- See Also:
-
isClassifierOfType
public static boolean isClassifierOfType(Collection<? extends Classifier> classifiers, Classifier type) Tests if there is at least one classifier among given ones which isTypeOf (equals or is derived) given type.- Parameters:
classifiers
- the given classifiertype
- the given type- Returns:
- true if classifiers contains at least one classifier which isTypeOf type
-
isSameOrDerivedClassifier
public static boolean isSameOrDerivedClassifier(@CheckForNull Classifier parent, @CheckForNull Classifier child) Checks if given classifier "child" is same as "parent" or is derived from "parent".- Parameters:
parent
- parent classifierchild
- child classifier- Returns:
- true if same or derived
- See Also:
-
isDerivedClassifier
public static boolean isDerivedClassifier(@CheckForNull Classifier parent, @CheckForNull Classifier child) Checks if given classifier "child" is derived from "parent".- Parameters:
parent
- parent classifierchild
- child classifier- Returns:
- true if derived
- See Also:
-
getDirectDerivedClassifiers
Return classifiers derived directly from the given classifier- Parameters:
general
- general classifier- Returns:
- collection of direct derived classifiers
-
getClassifierOrDerived
@CheckForNull public static Classifier getClassifierOrDerived(Collection<? extends Classifier> classifiers, Classifier checkFor) Checks if classifier collection contains given classifier or any derived from it, and returns the first found- Parameters:
classifiers
- collection of classifiers to look incheckFor
- target classifier- Returns:
- returns classifier which equals to the given or is derived
-
getGeneralClassifiersRecursively
Returns all general classifiers including the indirect ones up to the hierarchy top.- Parameters:
specific
- classifier- Returns:
- general classifiers
- See Also:
-
collectGeneralClassifiersRecursively
public static <T extends Classifier> void collectGeneralClassifiersRecursively(Classifier specific, Collection<T> result) Collects all general classifiers including the indirect ones up to the hierarchy top.- Parameters:
specific
- classifierresult
- general classifiers
-
collectGeneralClassifiersRecursively
public static Collection<Classifier> collectGeneralClassifiersRecursively(Collection<? extends Classifier> classifiers) Returns all general classifiers including the indirect ones up to hierarchy top. Result includes given classifiers.- Parameters:
classifiers
- classifier- Returns:
- general elements
- See Also:
-
getDirectGeneralClassifiers
Returns general classifiers from which the given classifier is directly derived.- Parameters:
classifier
- classifier- Returns:
- direct general classifiers
- See Also:
-
isDerivedOrRealizes
Checks if classifier is derived from given type or realizes the given type.- Parameters:
classifier
- classifier to checktype
- type- Returns:
- true if derived or realizes
-
getRealizedInterfaces
Collects all realized interfaces by the given classifier directly.- Parameters:
classifier
- given classifier- Returns:
- a collection of realized interfaces(may be empty)
-
collectRealizedInterfacesRecursively
public static void collectRealizedInterfacesRecursively(Collection<? extends Classifier> classifiers, Collection<Interface> result) Collects all realized interfaces by the given classifiers and their general classifiers recursively.- Parameters:
classifiers
- classifiers to collect realized interfaces fromresult
- a collection to append interfaces to
-
collectInterfaceRealizations
public static List<InterfaceRealization> collectInterfaceRealizations(BehavioredClassifier classifier, Interface contract) Collects interface realizations for the given contract- Parameters:
classifier
- classifier that might realize the interfacecontract
- interface to check realizations for- Returns:
- a collection of interface realizations (may be empty)
-
collectInheritedRealizedInterfaces
public static void collectInheritedRealizedInterfaces(BehavioredClassifier classifier, Collection<Interface> result, boolean collectOwned) Collect inherited and directly realized interfaces from the given classifier- Parameters:
classifier
- classifierresult
- result collectioncollectOwned
- if true, collected also owned
-
collectInheritedEnumerationLiterals
public static void collectInheritedEnumerationLiterals(Enumeration enumeration, Collection<EnumerationLiteral> result, boolean collectOwned, boolean collectPrivate) Collect inherited and owned literals from the given enumeration.- Parameters:
enumeration
- enumerationresult
- result collectioncollectOwned
- if true, collected also ownedcollectPrivate
- if false, do not collect private
-
getAllLiterals
Return owned and inherited enumeration literals- Parameters:
enumeration
- enumeration- Returns:
- literals
-
getPropertiesWithoutRedefined
Gets owned and inherited properties without redefined ones.- Parameters:
classifier
- classifiers from which properties will be collected- Returns:
- owned and inherited properties without redefined ones.
-
removeRedefined
public static void removeRedefined(Collection<? extends RedefinableElement> major, Collection<? extends RedefinableElement>... additional) Removes redefined elements from a given major collection. Major collection is a result. Additional collections are optional and are used only for redefined elements collecting- Parameters:
major
- elements to remove redefined elements fromadditional
- elements to remove redefined elements from
-
isSameOrRedefined
public static boolean isSameOrRedefined(@CheckForNull Property first, @CheckForNull Property second) Check if given first property is the same as second property or first property is redefined by second property- Parameters:
first
- first propertysecond
- second property- Returns:
- first is the same as second or is redefined by second
-
getSameOrRedefined
Resolves given property to itself or property redefined in the given classifier.- Parameters:
classifier
- classifierproperty
- property to check- Returns:
- given property or redefined if classifier redefines given property directly or indirectly
-
isSecondTypeCompatibleToFirst
public static boolean isSecondTypeCompatibleToFirst(@CheckForNull Type firstType, @CheckForNull Type secondType, boolean checkRealizedInterfaces) Indicates if second parameter type is compatible to the first (is same type or a subtype).- Parameters:
firstType
- parameter, to which the 2nd parameter must be compatible.secondType
- parameter, which should be compatible to the 1st.checkRealizedInterfaces
- indicates if realized interfaces should be taken into account when checking type compatibility.- Returns:
- true if parameters are compatible, false otherwise.
-