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.

Vaibhav Jain
  • 33,887
  • 46
  • 110
  • 163
  • 2
    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. – John Saunders Feb 18 '11 at 20:10

1 Answers1

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.

Jan
  • 437
  • 4
  • 15