Package com.nomagic.magicdraw.uml2
Class Classifiers
- java.lang.Object
-
- com.nomagic.magicdraw.uml2.Classifiers
-
public class Classifiers extends java.lang.Object
Convenience utility methods that operate on or returnClassifier
elements.
-
-
Constructor Summary
Constructors Constructor Description Classifiers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Classifier>
voidcollectDerivedClassifiers(Classifier general, java.util.Collection<T> result)
Collect all derived classifiers recursively (not only the direct children).static <T extends Classifier>
voidcollectGeneralClassifiersRecursively(Classifier specific, java.util.Collection<T> result)
Collects all general classifiers including the indirect ones up to the hierarchy top.static java.util.Collection<Classifier>
collectGeneralClassifiersRecursively(java.util.Collection<? extends Classifier> classifiers)
Returns all general classifiers including the indirect ones up to hierarchy top.static void
collectInheritedEnumerationLiterals(Enumeration enumeration, java.util.Collection<EnumerationLiteral> result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned literals from the given enumeration.static void
collectInheritedRealizedInterfaces(BehavioredClassifier classifier, java.util.Collection<Interface> result, boolean collectOwned)
Collect inherited and directly realized interfaces from the given classifierstatic java.util.List<InterfaceRealization>
collectInterfaceRealizations(BehavioredClassifier classifier, Interface contract)
Collects interface realizations for the given contractstatic void
collectRealizedInterfacesRecursively(java.util.Collection<? extends Classifier> classifiers, java.util.Collection<Interface> result)
Collects all realized interfaces by the given classifiers and their general classifiers recursively.static java.util.List<EnumerationLiteral>
getAllLiterals(Enumeration enumeration)
Return owned and inherited enumeration literalsstatic Classifier
getClassifierOrDerived(java.util.Collection<? extends Classifier> classifiers, Classifier checkFor)
Checks if classifier collection contains given classifier or any derived from it, and returns the first foundstatic java.util.Collection<Classifier>
getDerivedClassifiers(Classifier general)
Get all derived classifiers for given classifier recursively.static java.util.Collection<Classifier>
getDirectDerivedClassifiers(Classifier general)
Return classifiers derived directly from the given classifierstatic java.util.Collection<Classifier>
getDirectGeneralClassifiers(Classifier classifier)
Returns general classifiers from which the given classifier is directly derived.static java.util.Collection<Classifier>
getGeneralClassifiersRecursively(Classifier specific)
Returns all general classifiers including the indirect ones up to the hierarchy top.static java.util.List<Property>
getPropertiesWithoutRedefined(Classifier classifier)
Gets owned and inherited properties without redefined ones.static java.util.List<Interface>
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 <T extends Classifier>
voidinternalCollectDerivedClassifiers(Classifier general, java.util.Collection<T> result)
static <T extends Classifier>
voidinternalCollectGeneralClassifiersRecursively(Classifier specific, java.util.Collection<T> result)
static boolean
isClassifierOfType(java.util.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(java.util.Collection<? extends RedefinableElement> major, java.util.Collection<? extends RedefinableElement>... additional)
Removes redefined elements from a given major collection.
-
-
-
Method Detail
-
getDerivedClassifiers
public static java.util.Collection<Classifier> getDerivedClassifiers(Classifier general)
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, java.util.Collection<T> result)
Collect all derived classifiers recursively (not only the direct children).- Parameters:
general
- general classifierresult
- collection of all derived classifiers- See Also:
getDirectDerivedClassifiers(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier)
-
internalCollectDerivedClassifiers
public static <T extends Classifier> void internalCollectDerivedClassifiers(Classifier general, java.util.Collection<T> result)
-
isClassifierOfType
public static boolean isClassifierOfType(java.util.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(Classifier, Classifier)
-
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:
isDerivedClassifier(Classifier, Classifier)
-
getDirectDerivedClassifiers
public static java.util.Collection<Classifier> getDirectDerivedClassifiers(@CheckForNull Classifier general)
Return classifiers derived directly from the given classifier- Parameters:
general
- general classifier- Returns:
- collection of direct derived classifiers
-
getClassifierOrDerived
@CheckForNull public static Classifier getClassifierOrDerived(java.util.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
public static java.util.Collection<Classifier> getGeneralClassifiersRecursively(Classifier specific)
Returns all general classifiers including the indirect ones up to the hierarchy top.- Parameters:
specific
- classifier- Returns:
- general classifiers
- See Also:
getDirectGeneralClassifiers(Classifier)
-
collectGeneralClassifiersRecursively
public static <T extends Classifier> void collectGeneralClassifiersRecursively(Classifier specific, java.util.Collection<T> result)
Collects all general classifiers including the indirect ones up to the hierarchy top.- Parameters:
specific
- classifierresult
- general classifiers
-
internalCollectGeneralClassifiersRecursively
public static <T extends Classifier> void internalCollectGeneralClassifiersRecursively(Classifier specific, java.util.Collection<T> result)
-
collectGeneralClassifiersRecursively
public static java.util.Collection<Classifier> collectGeneralClassifiersRecursively(java.util.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:
getGeneralClassifiersRecursively(Classifier)
-
getDirectGeneralClassifiers
public static java.util.Collection<Classifier> getDirectGeneralClassifiers(Classifier classifier)
Returns general classifiers from which the given classifier is directly derived.- Parameters:
classifier
- classifier- Returns:
- direct general classifiers
- See Also:
getGeneralClassifiersRecursively(Classifier)
-
isDerivedOrRealizes
public static boolean isDerivedOrRealizes(Classifier classifier, Classifier type)
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
public static java.util.List<Interface> getRealizedInterfaces(BehavioredClassifier classifier)
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(java.util.Collection<? extends Classifier> classifiers, java.util.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 java.util.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, java.util.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, java.util.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
public static java.util.List<EnumerationLiteral> getAllLiterals(Enumeration enumeration)
Return owned and inherited enumeration literals- Parameters:
enumeration
- enumeration- Returns:
- literals
-
getPropertiesWithoutRedefined
public static java.util.List<Property> getPropertiesWithoutRedefined(Classifier classifier)
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(java.util.Collection<? extends RedefinableElement> major, java.util.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
public static Property getSameOrRedefined(Classifier classifier, Property property)
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.
-
-