Hi Andy,
Thanks for the response.
Actually, in this case of the interfaces, I reuse a sbsx unit with the interface definition by including it in other models, so each port should really use this interface definition and I think the equals method fits perfectly to my needs.
Anyhow, it's good to know that IBM implements equal. Knowing that it really point to the same element it will be quite obvious when to use an own comparison method.
Thanks for the clarification.
Best regards,
Robert
Internal
Original Message:
Sent: 12/16/2024 7:32:00 AM
From: Andy Lapping
Subject: RE: Compare Rhapsody elements via API
Hi Robert
Yes the Rhapsody API does override .equals but that will only return true if it really is the same element - you cant use it to compare two model elements to see if their content is the same. Are you comparing elements in the same model or two different models ? If its the same model then by nature the full path will be different as will the GUID. If you are comparing interfaces then you will need to compare by name, by signature (e.g. what arguments does the operation/event reception have and what are their types), direction (check the direction tag). What about other tags ? description ? etc etc
Ultimately you will have to determine what 'same' means and implement that yourself.
Cheers
Andy
------------------------------
Andy Lapping
Technical Fellow
Sodius Willert
Cwmbran
------------------------------
Original Message:
Sent: Fri December 13, 2024 05:04 AM
From: Robert Fromm
Subject: Compare Rhapsody elements via API
Hello,
acually, I want to compare two Rhapsody elements using the Java Api, like if two ports use the same interface contracts. The same means that they really use the same Rhapsody element. Indeed it might be that due to different versions, the Interface definitions even might differ ins some aspects, but this is not to be taken into account (yet).
Currently I see two possibilities:
- use the Java equals method i.e.
contract 1.equals(contract2) - take some string elements (like path name, GUID ...) and compare them like
contract1.getFullPathName().compareTo(contract2.getFullPathName()) == 0
Actually, I'm not shure what IBM does? Did they override the equals and implement some meaningful comparison, so that equals is safe?
Should I implement own comparators?
What is the preferred way to compare two Rhapsody objects for equality?
Best regards
Robert
------------------------------
Robert Fromm
------------------------------