UML. Generic class with limited parameter
Asked Answered
M

1

6

I have the following generic class header in Java:

class OrganizedGroup <T extends Leader> 

The class represents an organized group. For instance, a music group would have a music leader, an enterprise would have a boss...

How can I represent the condition T extends Leader using UML?

REMARK/EDIT:

There are different so questions that ask about generics and UML. However, my question asks about and additional restriction the parameter should be shown in the diagram as subclass of another class.

Mincemeat answered 2/9, 2015 at 20:16 Comment(1)
possible duplicate of UML Class Diagram and GenericsHolily
D
9

You would show that as template parameter with a constraint as such:

enter image description here

Note: actually I reverse engineered the class with Enterprise Architect and this is the result.

Dressmaker answered 3/9, 2015 at 9:31 Comment(1)
The good news: it's affordable and UML2 compliant. The bad news: it's a bit awkward in use. But you can't have everything ;-)Dressmaker

© 2022 - 2024 — McMap. All rights reserved.