6

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 ?

1 Answer 1

24

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.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.