You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can one set the multiplicity for a reference? For example, let authors be a reference variable in class Book to Person. A book can have zero or more authors. How to set the multiplicity lower and upper bounds for the variable authors in class Book?
Thank you for your help.
The text was updated successfully, but these errors were encountered:
Thanks for the ticket, once again, as you probably saw, the way of setting a cardinality for a Property is really really not straight forward.
You need to deal with the upperValue and lowerValue property of the Property object, but you don't need to directly put an integer, but a ValueSpecification instance instead.
Typically, you can use LiteralInteger for simple integer values and LiteralUnlimitedNatural for multiple value (for the upper bound).
Here is how to define a property with a cardinality 0..* and 1..5:
importpyuml2.umlasuml2# cardinality 0..*p=uml2.Property()
p.lowerValue=uml2.LiteralInteger(value=0)
p.upperValue=uml2.LiteralUnlimitedNatural(value=-1) # will be encoded and serialized as "*"# cardinality 1..5p=uml2.Property()
p.lowerValue=uml2.LiteralInteger(value=1)
p.upperValue=uml2.LiteralInteger(value=5)
How can one set the multiplicity for a reference? For example, let authors be a reference variable in class Book to Person. A book can have zero or more authors. How to set the multiplicity lower and upper bounds for the variable authors in class Book?
Thank you for your help.
The text was updated successfully, but these errors were encountered: