Package com.nomagic.magicdraw.uml
Class Refactoring
java.lang.Object
com.nomagic.magicdraw.uml.Refactoring
To refactor an element in a model, use the Refactoring class.
Example 1: Converting an element to an interface
Element elementToConvert = ...;
SessionManager sessionManager = SessionManager.getInstance();
sessionManager.createSession("Convert");
// Converts the element to an interface.
ConvertElementInfo info = new ConvertElementInfo(Interface.class);
// Preserves the old element ID for the new element.
info.setPreserveElementID(true);
Element conversionTarget = Refactoring.Converting.convert(elementToConvert, info);
sessionManager.closeSession();
Example 2: Replacing an element with another element
Element elementToReplace = ...;
SessionManager sessionManager = SessionManager.getInstance();
sessionManager.createSession("Replace");
ConvertElementInfo info = new ConvertElementInfo(elementToReplace.getClassType());
info.setConvertOnlyIncomingReferences(true);
Refactoring.Replacing.replace(element, elementToReplace, info);
sessionManager.closeSession();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConverts elements in the model.static classExtracts part of the model into a new reusable piece of model.static classMoves elements in model to a new owner element with or without connected relations An example how to move elements together with their relations:static final classReconnects one relation so that it skips selected part of the model.static classReverses direction of a relationship.static classReplaces elements in the model. -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Refactoring
public Refactoring()
-