Add nullable attribute to a class in enterprise architect
Asked Answered
A

1

9

I am using enterprise architect for UML. I need to generate code from the model. I need have a nullable double attribute in a class. I am able to add a double attribute but don't know how to make it nullable.

Do anyone have any idea how to add a nullable attribute.

Alber answered 18/2, 2011 at 19:46 Comment(1)
The generic answer to this kind of question is to create a class that looks like the one you want to generate, then reverse-engineer the class. Look to see what EA put on the attribute.Denouement
O
14

There is a small problems with your question, let me first answer the part about the EA, and get to it later.

In UML you denote nullable type as

  • +attributeName : TypeName [0..1]
  • +fromUser : User [0..1]

in EA this is done in the Multiplicity section Select the class->Hit F9->Select the attribute->Click detail

Lower bound and Upper bound are the fields you are looking for, if each are 1 this attribute has a single value [1] usually not depicted in the diagram

  • [0..1] can have a value of null.
  • [*] can have any amount of values.
  • [1..*] collection that contains at least one value
  • [n..m] collection that contains between n and m values. n and m are replaced by concrete numbers

in many languages double is a primitive/value type you can not make it null. If you need to, you have to use Double. Note the first letter is capital.

Optimal answered 22/8, 2013 at 12:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.