Package com.nomagic.uml2.ext.jmi.helpers
Class ClassifierHelper
- java.lang.Object
-
- com.nomagic.uml2.ext.jmi.helpers.CoreHelper
-
- com.nomagic.uml2.ext.jmi.helpers.ValueSpecificationHelper
-
- com.nomagic.uml2.ext.jmi.helpers.ClassifierHelper
-
- Direct Known Subclasses:
InstanceSpecificationHelper
@OpenApiAll public class ClassifierHelper extends ValueSpecificationHelper
Utility class for working with UML classifiers
-
-
Constructor Summary
Constructors Constructor Description ClassifierHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
areEqualParameterTypes(BehavioralFeature feature1, BehavioralFeature feature2)
Method compares parameters and returns true if parameters types are equals.static boolean
areEqualParameterTypes(BehavioralFeature feature1, BehavioralFeature feature2, boolean compareReturnParameter)
Method compares parameters and returns true if parameters types are equals.static java.util.Iterator<Association>
associations(Classifier classifier)
Get iterator of association from given classifier.static java.util.Iterator<Association>
associationsIncludingInherited(Classifier classifier)
Collects connected directly and inherited associationsstatic java.util.Iterator<Property>
attributes(Classifier classifier)
Get iterator of Attribute from given classifier.static Classifier
checkForDerivedClassifier(java.util.Collection<? extends Classifier> classifiers, Classifier checkFor)
Checks if there are given classifier or some derived classifier in a given classifier collection.static void
collectBaseClassInheritableAttributes(Classifier classifier, java.util.Collection result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned attributes from the given classifier.static java.util.Collection<Association>
collectCommonAssociations(java.util.Collection<? extends Classifier> classifiers1, java.util.Collection<? extends Classifier> classifiers2)
Collect association connected between given classifiersstatic void
collectDerivedClassifiersRecursively(java.util.Collection<? extends Classifier> result, Classifier general)
Collect all derived classifiers recursively (not only the direct children).static <T extends Classifier>
java.util.Collection<T>collectGeneralClassifiersAndRealizedInterfacesRecursively(Classifier classifier, java.util.Collection<T> result)
Collects all general classifiers including the indirect ones up to hierarchy top.static <T extends Classifier>
java.util.Collection<T>collectGeneralClassifiersRecursively(Classifier classifier, java.util.Collection<T> result)
Collects all general classifiers including the indirect ones up to hierarchy top.static void
collectInheritedAttributes(Classifier classifier, java.util.Collection result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned attributes from the given classifier.static void
collectInheritedBehaviors(BehavioredClassifier classifier, java.util.Collection<Behavior> result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned behaviors from the given classifierstatic void
collectInheritedEnumerationLiterals(Enumeration enumeration, java.util.Collection result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned literals from the given enumeration.static void
collectInheritedExtensionPoints(UseCase useCase, java.util.Collection result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned extension points from the given use case.static void
collectInheritedOperations(Classifier classifier, java.util.Collection result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned operations from the given classifier.static void
collectInheritedPorts(Classifier classifier, java.util.Collection result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned ports from the given classifier.static void
collectInheritedPureAttributes(Classifier classifier, java.util.Collection result, boolean collectOwned)
Collect inherited and owned attributes (just Property, not Port and etc) from the given classifier.static void
collectInheritedPureAttributes(Classifier classifier, java.util.Collection result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned attributes (just Property, not Port and etc) from the given classifier.static void
collectInheritedRealizedInterfaces(BehavioredClassifier classifier, java.util.Collection result, boolean collectOwned)
Collect inherited and directly realized interfaces from the given classifierstatic void
collectInheritedReceptions(Classifier classifier, java.util.Collection result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned receptions from the given classifierstatic void
collectInheritedRelations(Classifier classifier, java.util.Collection<Element> result, boolean collectOwned)
Collect inherited and directly connected relationships to the classifierstatic void
collectRealizedInterfaces(java.util.Collection<? extends Classifier> classifiers, java.util.Collection<Interface> result)
Collects realized interfaces by given classifiers.static Property
findAssociationEndForType(Classifier classifier, Classifier type, java.lang.String name)
Looks for AssociationEnd connected to the given classifier 'classifier' which can be mapped into 'classifier' attribute with name 'name' and type 'type'.static Generalization
findGeneralization(Classifier general, Classifier specific)
Look for generalization between given classifiers.static InterfaceRealization
findInterfaceRealization(BehavioredClassifier implementingClass, Interface contract)
Look for interface realization between given class and interface.static java.util.List<EnumerationLiteral>
getAllLiterals(Enumeration enumeration)
Return owned and inherited enumeration literalsstatic java.util.Collection<TypedElement>
getAssociationEndOwnedByAssociation(Classifier classifier)
Returns a collection of properties connected to given classifier by associations.static java.util.Collection<Classifier>
getClassifiersIncludingDerived(java.util.Collection<Classifier> generalClassifiers)
Returns set of provided classifiers plus directly derived onesstatic java.util.Collection<Classifier>
getClassifiersIncludingDerivedRecursively(java.util.Collection<? extends Classifier> classifiers)
Returns all general classifiers including the indirect ones down to the leafs of the hierarchy.static java.util.List<Classifier>
getClassifiersIncludingGeneralRecursively(Classifier classifier)
Returns all general classifiers including the indirect ones up to hierarchy top.static java.util.Collection<Classifier>
getClassifiersIncludingGeneralRecursively(java.util.Collection<? extends Classifier> classifiers)
Returns all general classifiers including the indirect ones up to hierarchy top.static java.util.Collection<Classifier>
getDerivedClassifiers(Classifier general)
Return classifiers derived directly from the given classifierstatic java.util.Collection<Classifier>
getDerivedClassifiersRecursively(Classifier general)
Get all derived classifiers for given classifier.static java.util.List<Classifier>
getGeneralClassifiers(Classifier classifier)
Returns general classifiers from which the given classifier is directly derived.static java.util.List<Classifier>
getGeneralClassifiersRecursively(Classifier classifier)
Returns all general classifiers including the indirect ones up to hierarchy top.static java.util.List<BehavioredClassifier>
getImplementedClasses(Interface anInterface)
Gets classifiers which realize (implement) a given interface.static int
getInheritanceDeep(Classifier classifier)
Gets the deep of inherited tree for classifier.static java.util.List<Parameter>
getParameters(BehavioralFeature feature)
Returns parameters without return parameterstatic java.util.List<Property>
getPropertiesWithoutRedefined(Classifier classifier)
Gets owned and inherited properties without redefined ones.static java.util.Collection<Interface>
getProvided(Class component)
Component provided interfaces collection consists of: 1) interfaces, realized by the component throughInterfaceRealization
, 2) provided interfaces of the component ports, 3) component port types which are interfaces.static java.util.List<Interface>
getRealizedInterfaces(BehavioredClassifier classifier)
Collects realized interfaces by the given classifier.static Parameter
getReturnParameter(BehavioralFeature feature)
Return parameter of given behaviour feature.static Parameter
getReturnParameter(BehavioralFeature feature, boolean create)
Return parameter of given behaviour feature.static Parameter
getReturnParameter(Behavior behavior, boolean create)
Return parameter of given behaviour.static java.util.List<Parameter>
getReturnParameters(BehavioralFeature feature)
Returns parameters without return parameterstatic boolean
isBehavioralFeatureEqual(BehavioralFeature feature1, BehavioralFeature feature2, boolean compareReturnParameter)
Compare the two given features by name and by parametersstatic boolean
isClassifierOfType(Classifier classifier, Classifier type)
Tests if given classifier isTypeOf (equals or is derived) given type.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 child is derived from parent by generalizationstatic boolean
isDerivedOrRealizes(Classifier classifier, Classifier type)
Checks if classifier is derived from given type or realizes the given type.static boolean
isLegalInheritance(Classifier parent, Classifier child)
Checks if new generalization relationship is legal between given parent and child.static boolean
isLegalInheritance(Classifier parent, Classifier child, java.util.Collection<? extends Relationship> ignore)
Checks if new generalization relationship is legal between given parent and child.static boolean
isOperationEqual(Operation op1, Operation op2)
Compare the two given operation.static boolean
isReturnParameter(Parameter parameter)
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 boolean
isSecondTypeCompatibleToFirst(Type firstType, java.util.Collection<Type> secondType, boolean checkRealizedInterfaces)
Indicates at least one type from second type collection is compatible to the first type.static java.util.Iterator<Operation>
operations(Classifier classifier)
Get iterator of operations from given classifier.static java.util.Iterator<Port>
ports(Classifier classifier)
Get iterator of port from given classifier.static java.util.Iterator<Property>
pureAttributes(Classifier classifier)
Get iterator of pure attribute from given classifier.static java.util.Iterator<Reception>
receptions(Classifier classifier)
Get iterator of reception from given classifier.static java.util.Collection<Classifier>
removeDerivedClassifiers(java.util.Collection<Classifier> classifiers)
Given a collection of classifiers, returns a collection without derived classifiers in their generalization hierarchy.static void
removeRedefined(java.util.Collection<? extends RedefinableElement> major, java.util.Collection<? extends RedefinableElement>... additional)
Removes redefined elements from a given major collection.-
Methods inherited from class com.nomagic.uml2.ext.jmi.helpers.ValueSpecificationHelper
cloneValueSpecification, createValueSpecification, createValueSpecification, createValueSpecification, createValueSpecification, createValueSpecification, getValueSpecificationClass, getValueSpecificationClass, getValueSpecificationValue, getValueString, isValueSpecificationClassElementValue, setValueDisposeIfNeeded, setValueSpecificationValue, setValueSpecificationValue, setValueSpecificationValue
-
Methods inherited from class com.nomagic.uml2.ext.jmi.helpers.CoreHelper
areElementsEditable, canAddChild, canAssignName, canAssignName, canAssignName, canMoveChildInto, canMoveChildInto, collectRelationships, collectRelationships, collectRelationshipsByType, collectRelationshipsIncludeIndirect, dispose, findAcceptableParentFor, findAcceptableParentFor, findOwnerOfStrictType, findOwnerOfStrictTypeIncludingItself, findOwnerOfType, findOwnerOfTypeIncludingItself, findParent, findParent, getAdditionalElementsIterator, getClientElement, getComment, getCommentElement, getCommentElementOrCreate, getDependentClients, getDependentSuppliers, getFirstMemberEnd, getMultiplicity, getName, getOppositeEnd, getOwnedElementsIncludingAdditional, getSecondMemberEnd, getSupplierElement, getSupplierElement, getSupplierElements, hasParentIn, isChildOf, isDocumentationComment, isMultiplicityMany, isParentOf, isParentOf, isRelationship, isRelationshipAlwaysInClient, parseMultiplicityString, setClientElement, setComment, setCommentElement, setConstraintText, setConstraintText, setMultiplicity, setMultiplicity, setSupplierElement
-
-
-
-
Method Detail
-
getDerivedClassifiersRecursively
public static java.util.Collection<Classifier> getDerivedClassifiersRecursively(Classifier general)
Get all derived classifiers for given classifier. Result does not include the given classifier.- Parameters:
general
- given classifier to collect specific classifiers for- Returns:
- collection of all derived classifiers
-
getClassifiersIncludingDerivedRecursively
public static java.util.Collection<Classifier> getClassifiersIncludingDerivedRecursively(java.util.Collection<? extends Classifier> classifiers)
Returns all general classifiers including the indirect ones down to the leafs of the hierarchy. Result includes given classifiers.- Parameters:
classifiers
- classifiers- Returns:
- general elements
- See Also:
getGeneralClassifiersRecursively(Classifier)
-
collectDerivedClassifiersRecursively
public static void collectDerivedClassifiersRecursively(java.util.Collection<? extends Classifier> result, Classifier general)
Collect all derived classifiers recursively (not only the direct children).- Parameters:
result
- collection of all derived classifiersgeneral
- general classifier
-
getDerivedClassifiers
public static java.util.Collection<Classifier> getDerivedClassifiers(@CheckForNull Classifier general)
Return classifiers derived directly from the given classifier- Parameters:
general
- general classifier- Returns:
- collection of derived classifiers
-
getClassifiersIncludingDerived
public static java.util.Collection<Classifier> getClassifiersIncludingDerived(java.util.Collection<Classifier> generalClassifiers)
Returns set of provided classifiers plus directly derived ones- Parameters:
generalClassifiers
- classifier collection- Returns:
- collection of classifiers including derived
- See Also:
getClassifiersIncludingDerivedRecursively(java.util.Collection<? extends com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier>)
-
getGeneralClassifiers
public static java.util.List<Classifier> getGeneralClassifiers(Classifier classifier)
Returns general classifiers from which the given classifier is directly derived.- Parameters:
classifier
- classifier- Returns:
- direct general classifiers
- See Also:
getGeneralClassifiersRecursively(Classifier)
-
getGeneralClassifiersRecursively
public static java.util.List<Classifier> getGeneralClassifiersRecursively(Classifier classifier)
Returns all general classifiers including the indirect ones up to hierarchy top. Result does not include the given classifier.- Parameters:
classifier
- classifier- Returns:
- general elements
- See Also:
getGeneralClassifiers(Classifier)
-
getClassifiersIncludingGeneralRecursively
public static java.util.List<Classifier> getClassifiersIncludingGeneralRecursively(Classifier classifier)
Returns all general classifiers including the indirect ones up to hierarchy top. Result includes given classifier.- Parameters:
classifier
- classifier- Returns:
- general elements
- See Also:
getGeneralClassifiers(Classifier)
-
getClassifiersIncludingGeneralRecursively
public static java.util.Collection<Classifier> getClassifiersIncludingGeneralRecursively(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)
-
collectGeneralClassifiersRecursively
public static <T extends Classifier> java.util.Collection<T> collectGeneralClassifiersRecursively(Classifier classifier, java.util.Collection<T> result)
Collects all general classifiers including the indirect ones up to hierarchy top.- Parameters:
classifier
- classifierresult
- result collection- Returns:
- result collection
-
collectGeneralClassifiersAndRealizedInterfacesRecursively
public static <T extends Classifier> java.util.Collection<T> collectGeneralClassifiersAndRealizedInterfacesRecursively(Classifier classifier, java.util.Collection<T> result)
Collects all general classifiers including the indirect ones up to hierarchy top. Also collects all realized interfaces from the collected general classifiers.- Parameters:
classifier
- classifierresult
- result collection- Returns:
- result collection
-
getInheritanceDeep
public static int getInheritanceDeep(Classifier classifier)
Gets the deep of inherited tree for classifier. Used to sort stereotypes by inheritance.- Parameters:
classifier
- classifier- Returns:
- result deep
-
isLegalInheritance
public static boolean isLegalInheritance(Classifier parent, Classifier child)
Checks if new generalization relationship is legal between given parent and child. Legal if it does not create cycle and child isKindOf parent.- Parameters:
parent
- parent element of generalization.child
- child element of generalization.- Returns:
- true - if generalization is legal, otherwise return false.
-
isLegalInheritance
public static boolean isLegalInheritance(Classifier parent, Classifier child, @CheckForNull java.util.Collection<? extends Relationship> ignore)
Checks if new generalization relationship is legal between given parent and child. Legal if it does not create cycle and child isKindOf parent.- Parameters:
parent
- parent element of generalization.child
- child element of generalization.ignore
- a collection of classifiers that should be ignored.- Returns:
- true - if generalization is legal, otherwise return false.
-
findAssociationEndForType
@CheckForNull public static Property findAssociationEndForType(Classifier classifier, Classifier type, java.lang.String name)
Looks for AssociationEnd connected to the given classifier 'classifier' which can be mapped into 'classifier' attribute with name 'name' and type 'type'.- Parameters:
classifier
- the given classifier.type
- the type of the association end.name
- the name of the association end.- Returns:
- found AssociationEnd or null.
-
getReturnParameter
public static Parameter getReturnParameter(BehavioralFeature feature)
Return parameter of given behaviour feature. A new parameter is created if feature does not have it.- Parameters:
feature
- a given feature- Returns:
- return parameter (existing one or created)
-
isReturnParameter
public static boolean isReturnParameter(Parameter parameter)
- Parameters:
parameter
- parameter- Returns:
- true if given Parameter has return kind
-
getReturnParameter
@CheckForNull public static Parameter getReturnParameter(BehavioralFeature feature, boolean create)
Return parameter of given behaviour feature. A new parameter may be created if feature does not have it.- Parameters:
feature
- a given featurecreate
- creates a new parameter if needed- Returns:
- return parameter
-
getReturnParameter
@CheckForNull public static Parameter getReturnParameter(Behavior behavior, boolean create)
Return parameter of given behaviour. A new parameter may be created if behavior does not have it.- Parameters:
behavior
- a given behaviorcreate
- creates a new parameter if needed- Returns:
- return parameter
-
operations
public static java.util.Iterator<Operation> operations(Classifier classifier)
Get iterator of operations from given classifier.- Parameters:
classifier
- The given classifier.- Returns:
- iterator
-
receptions
public static java.util.Iterator<Reception> receptions(Classifier classifier)
Get iterator of reception from given classifier.- Parameters:
classifier
- The given classifier.- Returns:
- iterator
-
attributes
public static java.util.Iterator<Property> attributes(Classifier classifier)
Get iterator of Attribute from given classifier.- Parameters:
classifier
- The given classifier.- Returns:
- iterator
-
ports
public static java.util.Iterator<Port> ports(Classifier classifier)
Get iterator of port from given classifier.- Parameters:
classifier
- The given classifier.- Returns:
- iterator
-
pureAttributes
public static java.util.Iterator<Property> pureAttributes(Classifier classifier)
Get iterator of pure attribute from given classifier.- Parameters:
classifier
- The given classifier.- Returns:
- iterator
-
associations
public static java.util.Iterator<Association> associations(Classifier classifier)
Get iterator of association from given classifier.- Parameters:
classifier
- The given classifier.- Returns:
- iterator
-
associationsIncludingInherited
public static java.util.Iterator<Association> associationsIncludingInherited(Classifier classifier)
Collects connected directly and inherited associations- Parameters:
classifier
- classifier
-
collectInheritedAttributes
public static void collectInheritedAttributes(Classifier classifier, java.util.Collection result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned attributes from the given classifier.- Parameters:
classifier
- classifierresult
- result collectioncollectOwned
- if true, collected also ownedcollectPrivate
- if false, do not collect private
-
collectBaseClassInheritableAttributes
public static void collectBaseClassInheritableAttributes(Classifier classifier, java.util.Collection result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned attributes from the given classifier.- Parameters:
classifier
- classifierresult
- result collectioncollectOwned
- if true, collected also ownedcollectPrivate
- if false, do not collect private
-
collectInheritedPureAttributes
public static void collectInheritedPureAttributes(Classifier classifier, java.util.Collection result, boolean collectOwned)
Collect inherited and owned attributes (just Property, not Port and etc) from the given classifier. Private attributes are collected.- Parameters:
classifier
- classifierresult
- result collectioncollectOwned
- if true, collected also owned
-
collectInheritedPureAttributes
public static void collectInheritedPureAttributes(Classifier classifier, java.util.Collection result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned attributes (just Property, not Port and etc) from the given classifier.- Parameters:
classifier
- classifierresult
- result collectioncollectOwned
- if true, collected also ownedcollectPrivate
- if false, do not collect private
-
collectInheritedRelations
public static void collectInheritedRelations(Classifier classifier, java.util.Collection<Element> result, boolean collectOwned)
Collect inherited and directly connected relationships to the classifier- Parameters:
classifier
- classifierresult
- result collectioncollectOwned
- if true, collected also owned
-
getAssociationEndOwnedByAssociation
public static java.util.Collection<TypedElement> getAssociationEndOwnedByAssociation(Classifier classifier)
Returns a collection of properties connected to given classifier by associations. Properties are owned by Association- Parameters:
classifier
- the given classifier- Returns:
- collection of properties
-
collectInheritedPorts
public static void collectInheritedPorts(Classifier classifier, java.util.Collection result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned ports from the given classifier.- Parameters:
classifier
- classifierresult
- result collectioncollectOwned
- if true, collected also ownedcollectPrivate
- if false, do not collect private
-
collectInheritedExtensionPoints
public static void collectInheritedExtensionPoints(UseCase useCase, java.util.Collection result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned extension points from the given use case.- Parameters:
useCase
- use caseresult
- result collectioncollectOwned
- if true, collected also ownedcollectPrivate
- if false, do not collect private
-
collectInheritedOperations
public static void collectInheritedOperations(Classifier classifier, java.util.Collection result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned operations from the given classifier.- Parameters:
classifier
- classifierresult
- result collectioncollectOwned
- if true, collected also ownedcollectPrivate
- if false, do not collect private
-
collectInheritedBehaviors
public static void collectInheritedBehaviors(BehavioredClassifier classifier, java.util.Collection<Behavior> result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned behaviors from the given classifier- Parameters:
classifier
- classifierresult
- result collectioncollectOwned
- if true, collected also ownedcollectPrivate
- if false, do not collect private
-
collectInheritedReceptions
public static void collectInheritedReceptions(Classifier classifier, java.util.Collection result, boolean collectOwned, boolean collectPrivate)
Collect inherited and owned receptions from the given classifier- Parameters:
classifier
- classifierresult
- result collectioncollectOwned
- if true, collected also ownedcollectPrivate
- if false, do not collect private
-
collectInheritedRealizedInterfaces
public static void collectInheritedRealizedInterfaces(BehavioredClassifier classifier, java.util.Collection result, boolean collectOwned)
Collect inherited and directly realized interfaces from the given classifier- Parameters:
classifier
- classifierresult
- result collectioncollectOwned
- if true, collected also owned
-
getAllLiterals
public static java.util.List<EnumerationLiteral> getAllLiterals(Enumeration enumeration)
Return owned and inherited enumeration literals- Parameters:
enumeration
- enumeration- Returns:
- literals
-
collectInheritedEnumerationLiterals
public static void collectInheritedEnumerationLiterals(Enumeration enumeration, java.util.Collection 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
-
isClassifierOfType
public static boolean isClassifierOfType(Classifier classifier, Classifier type)
Tests if given classifier isTypeOf (equals or is derived) given type.- Parameters:
classifier
- the give classifiertype
- the given type- Returns:
- true if classifier isTypeOf type
-
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
-
getRealizedInterfaces
public static java.util.List<Interface> getRealizedInterfaces(BehavioredClassifier classifier)
Collects realized interfaces by the given classifier.- Parameters:
classifier
- given classifier- Returns:
- a collection of realized interfaces(may be empty)
-
checkForDerivedClassifier
@CheckForNull public static Classifier checkForDerivedClassifier(java.util.Collection<? extends Classifier> classifiers, Classifier checkFor)
Checks if there are given classifier or some derived classifier in a given classifier collection.- Parameters:
classifiers
- collection of classifiers to look incheckFor
- target classifier- Returns:
- returns classifier which equals to the given or is derived
-
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:
Classifiers.isDerivedClassifier(Classifier, Classifier)
-
isDerivedClassifier
public static boolean isDerivedClassifier(@CheckForNull Classifier parent, @CheckForNull Classifier child)
Checks if child is derived from parent by generalization- Parameters:
parent
- parentchild
- possible parent- Returns:
- true if derived
-
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
-
isSecondTypeCompatibleToFirst
public static boolean isSecondTypeCompatibleToFirst(Type firstType, java.util.Collection<Type> secondType, boolean checkRealizedInterfaces)
Indicates at least one type from second type collection is compatible to the first type.- Parameters:
firstType
- type to which types should be checked.secondType
- types which should be compared to the first type.checkRealizedInterfaces
- indicates if realized interfaces should be taken into account when checking type compatibility.- Returns:
- true if parameters are compatible, false otherwise.
-
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.
-
collectRealizedInterfaces
public static void collectRealizedInterfaces(java.util.Collection<? extends Classifier> classifiers, java.util.Collection<Interface> result)
Collects realized interfaces by given classifiers.- Parameters:
classifiers
- classifiers for which realized interfaces should be collected.result
- a set in which realized interfaces should be collected.
-
removeDerivedClassifiers
public static java.util.Collection<Classifier> removeDerivedClassifiers(java.util.Collection<Classifier> classifiers)
Given a collection of classifiers, returns a collection without derived classifiers in their generalization hierarchy.- Parameters:
classifiers
- classifier hierarchy to optimize- Returns:
- optimized classifier hierarchy.
-
isOperationEqual
public static boolean isOperationEqual(Operation op1, Operation op2)
Compare the two given operation.- Parameters:
op1
- First operation.op2
- Second operation.- Returns:
- boolean
-
isBehavioralFeatureEqual
public static boolean isBehavioralFeatureEqual(BehavioralFeature feature1, BehavioralFeature feature2, boolean compareReturnParameter)
Compare the two given features by name and by parameters- Parameters:
feature1
- first featurefeature2
- second featurecompareReturnParameter
- take into account return parameter(s)- Returns:
- true if names are equals and parameters are equals
-
areEqualParameterTypes
public static boolean areEqualParameterTypes(BehavioralFeature feature1, BehavioralFeature feature2)
Method compares parameters and returns true if parameters types are equals.- Parameters:
feature1
- feature to be compared with.feature2
- feature to be compared with.- Returns:
- true if parameters are equals.
-
areEqualParameterTypes
public static boolean areEqualParameterTypes(BehavioralFeature feature1, BehavioralFeature feature2, boolean compareReturnParameter)
Method compares parameters and returns true if parameters types are equals.- Parameters:
feature1
- feature to be compared with.feature2
- feature to be compared with.compareReturnParameter
- take into account return parameter(s)- Returns:
- true if parameters are equals.
-
findInterfaceRealization
@CheckForNull public static InterfaceRealization findInterfaceRealization(BehavioredClassifier implementingClass, Interface contract)
Look for interface realization between given class and interface.- Parameters:
implementingClass
- classcontract
- interface
-
findGeneralization
@CheckForNull public static Generalization findGeneralization(Classifier general, Classifier specific)
Look for generalization between given classifiers.- Parameters:
general
- general classifierspecific
- specific classifier
-
getParameters
public static java.util.List<Parameter> getParameters(BehavioralFeature feature)
Returns parameters without return parameter- Parameters:
feature
- the given feature
-
getReturnParameters
public static java.util.List<Parameter> getReturnParameters(BehavioralFeature feature)
Returns parameters without return parameter- Parameters:
feature
- the given feature
-
collectCommonAssociations
public static java.util.Collection<Association> collectCommonAssociations(java.util.Collection<? extends Classifier> classifiers1, java.util.Collection<? extends Classifier> classifiers2)
Collect association connected between given classifiers- Parameters:
classifiers1
- one classifiers collectionclassifiers2
- second classifiers collection- Returns:
- common Associations between two collections of classifiers
-
getProvided
public static java.util.Collection<Interface> getProvided(Class component)
Component provided interfaces collection consists of: 1) interfaces, realized by the component throughInterfaceRealization
, 2) provided interfaces of the component ports, 3) component port types which are interfaces.- Returns:
- provided interfaces.
-
getImplementedClasses
public static java.util.List<BehavioredClassifier> getImplementedClasses(Interface anInterface)
Gets classifiers which realize (implement) a given interface.- Parameters:
anInterface
- an interface for which to get classifiers.- Returns:
- list of classifiers which realize a given interface.
-
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 major
-
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
-
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.
-
-