Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UML. Generic class with limited parameter

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.

like image 644
Rodrigo Avatar asked Sep 02 '15 20:09

Rodrigo


People also ask

How many type parameters can be used in a generic class?

You can also use more than one type parameter in generics in Java, you just need to pass specify another type parameter in the angle brackets separated by comma.

Can a generic class have multiple generic parameters?

A Generic class can have muliple type parameters.

Can a generic class definition can only have one type parameter?

A generic method can have one or more type parameters, such as the "T" in countOccurrences.

What can a generic class be parameterized for?

Generics means parameterized types. The idea is to allow type (Integer, String, … etc., and user-defined types) to be a parameter to methods, classes, and interfaces. Using Generics, it is possible to create classes that work with different data types.


1 Answers

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.

like image 185
qwerty_so Avatar answered Oct 08 '22 01:10

qwerty_so