UML 中的注释 "NonNull"?

Anotation "NonNull" in UML?

Android Studio 正在显示注释

`@NonNull`

,我们如何用 UML 表示它?

同样,标注的显示有何标准?

NotNull 属性表示 属性 或关联端必须存在。

这等同于重数为 1 而不是 0..1 或未指定的重数。

如果将属性的多重性设置为 [1],它将变为 不可为空。

- someAttribute : int [1]

并且由于 1 是属性的默认多重性,您也可以不定义多重性。

- someAttribute : int

为了 允许 为空,你必须明确地将下限设置为 0

- someAttribute : int [0..1]

参见 UML 2.5 specification 第 9.5.4 章 (Property.Notation)

<multiplicity-range> is the multiplicity range of the Property. If this term is omitted, it implies a multiplicity of 1 (exactly one). (See MultiplicityElement – sub clause 7.5.)