Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify the return type of a method that returns a list of values in StarUML?

I have two classes (say Database and Record). In Database class, I have a method named getRecords() that returns a list of Record objects.

In Java, the above method can be written as:

List<Record> getRecords(){..}

In StarUML, while designing Class diagram, I tried giving

+getRecords() : Record[0..*]

But StarUML refused to create method like above. When I tried with the one below, it works

+getRecords() : ArrayList<Record>

But this is more specific to Java. I want to implement something like Record[0..*] in StarUML. Is it possible to write methods in such format or the Java style of return type is the only solution ?

like image 480
Harish R Avatar asked Mar 20 '18 16:03

Harish R


1 Answers

I don't know why StarUML refuses to parse the text, but you can still create it via model.

  1. Add the operation and call it getRecords()
  2. Right-click on the operation (in diagram or model), and select Add > Parameter
  3. Select parameter in Model Explorer (probably the parameter is already selected when you created it) and set the direction parameter to return. This is how UML represents return types.
  4. (Configure the type, multiplicity, and anything else you need.)

Note that the default collection in UML is Set, so you should check isOrdered, as List is an ordered collection.

like image 88
Peter Uhnak Avatar answered Oct 04 '22 05:10

Peter Uhnak