Package com.nomagic.uml2.ext.jmi.helpers
Class ModelHelper
Model Utility class.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
canAssignType
(TypedElement typedElement, Type type) Check if given Type can be assigned to a given TypedElement.static boolean
canChangeNavigability
(Property property) Checks if navigability of the association end property can be inverted - navigable to non-navigable and vice versa.static boolean
canChangeOwnerTo
(Property property, boolean toAssociation) Checks if association end can be owned by association or connected element.static void
changeOwnerTo
(Property property, boolean toAssociation) Changes ownership of the association end.static Image
createImage
(ElementsFactory factory, File file) Creates image model element from a given image found in a file.static Image
createImage
(ElementsFactory factory, String url) Creates image model element from a given image found at url.static Behavior
findBehaviorFor
(Element element) Finds a defining behavior for a given element.static Deployment
findDeployment
(DeploymentTarget deploymentTarget, DeployedArtifact artifact) Find existing deployment among target and artifactstatic NamedElement
Finds preferred owner element for the association end.static List<ActivityParameterNode>
getActivityParameterNodes
(Activity activity) Gets activity parameter nodes from a given activity.static BehavioredClassifier
getContext
(Behavior behavior) The classifier that is the context for the execution of the behavior.static ConnectorEnd
getFirstEnd
(Connector connector) Return a first connector endstatic ConnectorEnd
Gets opposite connector end for a given connector end.static ConnectorEnd
getSecondEnd
(Connector connector) Return a second connector endstatic boolean
isAggregation
(Association association, AggregationKind aggregationKind) Determines if association is of specified aggregation kind.static boolean
isDirectedAssociation
(Association association) Check if association is directedstatic boolean
isNonNavigableAssociation
(Association association) Check if association is non-navigablestatic boolean
isPropertyEqual
(Property p1, Property p2) Compare the two given Property.static void
setNavigable
(Property property, boolean navigable) Sets navigability of the specified association end.static void
setNavigable
(Property property, boolean navigable, boolean automaticOwnership) Sets navigability of the specified association end.Methods inherited from class com.nomagic.uml2.ext.jmi.helpers.InstanceSpecificationHelper
collectAllInstances, createSlot, createSlotsForDefaultValues, createSlotsForDefaultValues, findSlot, getAssignableAssociationsForLink, getAssociationOfLink, getLinksBetweenInstances, getNestedSlot, getSlot, getSlot, getValueBySlot, isInstanceSpecificationCompatibleWithType, isInstanceSpecificationCompatibleWithType, isLink, setClassifierForInstanceSpecification, setClassifierForInstanceSpecification, setSlotValue
Methods inherited from class com.nomagic.uml2.ext.jmi.helpers.ClassifierHelper
areEqualParameterTypes, areEqualParameterTypes, associations, associationsIncludingInherited, attributes, checkForDerivedClassifier, collectBaseClassInheritableAttributes, collectCommonAssociations, collectDerivedClassifiersRecursively, collectGeneralClassifiersAndRealizedInterfacesRecursively, collectGeneralClassifiersRecursively, collectInheritedAttributes, collectInheritedBehaviors, collectInheritedEnumerationLiterals, collectInheritedExtensionPoints, collectInheritedOperations, collectInheritedPorts, collectInheritedPureAttributes, collectInheritedPureAttributes, collectInheritedRealizedInterfaces, collectInheritedReceptions, collectInheritedRelations, collectRealizedInterfaces, findAssociationEndForType, findGeneralization, findInterfaceRealization, getAllLiterals, getAssociationEndOwnedByAssociation, getClassifiersIncludingDerived, getClassifiersIncludingDerivedRecursively, getClassifiersIncludingGeneralRecursively, getClassifiersIncludingGeneralRecursively, getDerivedClassifiers, getDerivedClassifiersRecursively, getGeneralClassifiers, getGeneralClassifiersRecursively, getImplementedClasses, getInheritanceDeep, getParameters, getPropertiesWithoutRedefined, getProvided, getRealizedInterfaces, getReturnParameter, getReturnParameter, getReturnParameter, getReturnParameters, isBehavioralFeatureEqual, isClassifierOfType, isClassifierOfType, isDerivedClassifier, isDerivedOrRealizes, isLegalInheritance, isLegalInheritance, isOperationEqual, isReturnParameter, isSameOrDerivedClassifier, isSameOrRedefined, isSecondTypeCompatibleToFirst, isSecondTypeCompatibleToFirst, operations, ports, pureAttributes, receptions, removeDerivedClassifiers, removeRedefined
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
-
Constructor Details
-
ModelHelper
public ModelHelper()
-
-
Method Details
-
getActivityParameterNodes
Gets activity parameter nodes from a given activity.- Parameters:
activity
- activity from which parameter nodes must be returned.- Returns:
- a list of activity parameter nodes of a given activity.
-
createImage
Creates image model element from a given image found in a file. The method does not start or check sessions.- Parameters:
file
- file in which to look for an image.- Returns:
- created image model element.
-
createImage
Creates image model element from a given image found at url. The method does not start or check sessions.- Parameters:
url
- url- Returns:
- created image model element.
-
isPropertyEqual
Compare the two given Property.- Parameters:
p1
- First propertyp2
- Second property- Returns:
- boolean
-
canChangeOwnerTo
Checks if association end can be owned by association or connected element.- Parameters:
property
- association end. Can not be nulltoAssociation
- indicates what kind of ownership shall be checked - true for association and false for connected element- Returns:
- true according to toAssociation argument: if association can own the association end or connected element can own the association end. Returns false if preferred owner is null
-
changeOwnerTo
Changes ownership of the association end. It can change owner of the property to association or connected element.- Parameters:
property
- association end. Can not be nulltoAssociation
- preferred owner: true for association and false for connected element
-
findOwner
Finds preferred owner element for the association end.- Parameters:
property
- association end. Can not be nullassociation
- preferred owner: true for association and false for connected element- Returns:
- model element or null if such element does not exist
-
findBehaviorFor
Finds a defining behavior for a given element. Only BehaviorClassifier and BehaviorFeature are taken into account- Parameters:
element
- element- Returns:
- behavior
-
isAggregation
Determines if association is of specified aggregation kind.- Parameters:
association
- association model element.aggregationKind
- AggregationKindEnum.SHARED - aggregation, AggregationKindEnum.COMPOSITE - composition.- Returns:
- true if one of association ends has set specified aggregation kind
-
isDirectedAssociation
Check if association is directed- Parameters:
association
- association- Returns:
- true if at least one end is navigable
-
findDeployment
@CheckForNull public static Deployment findDeployment(DeploymentTarget deploymentTarget, DeployedArtifact artifact) Find existing deployment among target and artifact- Parameters:
deploymentTarget
- targetartifact
- artifact- Returns:
- existing deployment or null
-
getContext
The classifier that is the context for the execution of the behavior. A Behavior that is directly owned as a nestedClassifier does not have a context. Otherwise, to determine the context of a Behavior, find the first BehavioredClassifier reached by following the chain of owner relationships from the Behavior, if any. If there is such a BehavioredClassifier, then it is the context, unless it is itself a Behavior with a non-empty context, in which case that is also the context for the original Behavior. For example, following this algorithm, the context of an entry action in a state machine is the classifier that owns the state machine. The features of the context classifier as well as the elements visible to the context classifier are visible to the behavior. (Subsets RedefinableElement::redefinitionContext)- Parameters:
behavior
- behavior for which to get the context.
-
canAssignType
Check if given Type can be assigned to a given TypedElement. For example Property owned by Stereotype (Tag definition) can be typed just by Stereotype, DataType or metaclass.- Parameters:
typedElement
- typed elementtype
- type- Returns:
- true if type can be changed
-
getFirstEnd
Return a first connector end- Parameters:
connector
- connector- Returns:
- end
-
getSecondEnd
Return a second connector end- Parameters:
connector
- connector- Returns:
- end
-
getOppositeEnd
Gets opposite connector end for a given connector end.- Parameters:
end
- connector end for which to get opposite end- Returns:
- opposite connector end for a given connector end
-