0

In Java, suppose I have a UML model in eclipse (org.eclipse.uml2.uml) and want to retrieve all the overridden attributes and methods from all classifiers, how do I do that?

I can get all attributes and methods from a classifier, with .getAllAttributes() and .getAllOperations(), but I only want to get those, which override methods/attributes from parent classes.

qwerty_so
  • 35,448
  • 8
  • 62
  • 86

2 Answers2

1

You can't (simply). The only way is to compare the attribute/operation names from class and superclass and pinpoint the duplicate ones.

See also Is there a convention for showing overridden methods in UML static class diagrams?

qwerty_so
  • 35,448
  • 8
  • 62
  • 86
  • Could we assume that the overridden Attribute/Operation redefine other Attribute/Operation. In that case, maybe that the getRedefinedElement() should do the job!? – Red Beard Jun 03 '19 at 08:25
  • 1
    Hmm. If the Eclipse API offers such an operation. Just post it as answer. – qwerty_so Jun 03 '19 at 08:38
0

It depends how your model was created but UML defines redefinedAttribute and redefinedOperation associations which can be used to model overridden Properties and Operations. In such case/model, you should be able to access to overridden Operation by using .getRedefinedOperation()...

enter image description here

Red Beard
  • 3,436
  • 1
  • 14
  • 17