Question & Answer
Question
How do you add a realization between classes using JAVA API in IBM Rational Rhapsody?
Cause
You would like to use Java Application Programming Interfaces [API] code to automate the manual task to be performed with in Rational Rhapsody.
Answer
In order to add a realization between classes in Rational Rhapsody you can use the API methods findGeneralization(String name) and changeTo(String metaclass).
Find below a code snippet for your reference:
All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
---|
IRPPackage myPkg = myPrj.addPackage("Test");
IRPClass myCls1 = myPkg.addClass("Class1");
IRPClass myCls2 = myPkg.addClass("Class2");
myCls1.addGeneralization((IRPClassifier)myCls2);
IRPGeneralization myGen = myCls1.findGeneralization(myCls2.getName());
myGen.changeTo("Realization");
Product Synonym
Rational Rhapsody
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
swg21588593