Inheritance 继承依赖于属性值的UML类图
示例如下:Inheritance 继承依赖于属性值的UML类图,inheritance,uml,class-diagram,Inheritance,Uml,Class Diagram,示例如下: ----------- -------------------- | X | 1..1 0..1 | <<abstract>> | | |<>------------| Y | |-----------| |--------------------| | +a:bool |
----------- --------------------
| X | 1..1 0..1 | <<abstract>> |
| |<>------------| Y |
|-----------| |--------------------|
| +a:bool | | +b:positiveInteger |
'-----------' '--------------------'
------------
|X | 1..10..1 ||
||-------------------Y|
|-----------| |--------------------|
|+a:bool | |+b:positiveInteger|
'-----------' '--------------------'
在现实世界中,根据以下规则,抽象Y可以是具体的a、B或C:
- 当
为a
时,Y为a类李>true
- 当
为a
且false
时,Y为b类李>b==1
- 当
为a
且false
时,Y为C类b>1
A
,B
,以及Y
的C
,然后您需要这样的OCL约束:
context X:
inv: (self.a implies self.y isOclTypeOf(A)) and
(((not self.a) and (not self.y.isOclUndefined())) implies (self.y.b = 1 implies self.y.isOclTypeOf(B))) and
(((not self.a) and (not self.y.isOclUndefined())) implies (self.y.b > 1 implies self.y.isOclTypeOf(C)))
我不会的。这些是侧约束,不属于类图本身。对于XML文档来说,似乎也很有效。