Reputation: 2062
Image the following: (<> indicates a black diamond, which refers to a composition in UML)
+---+ 0..1 * +---+
| A |<>--------| B |
+---+ +---+
I have class A and class B. A containment reference exists from A to B with multiplicity unbound. The opposite reference has multiplicity 0..1.
My question is: Isn't this opposite multiplicity wrong / impossible ?! Because in Ecore, the containment reference specifies that B can only exist if it as an A. Therefore the multiplicity from B to A is always 1, isn't it ?!
0..1 would mean that an instance of B can have an A or not.
UPDATE: my task is to transform the following UML diagram into Ecore
+---+ 0..1 * +---+ * 1 +---+
| A |<>--------| B |--------<>| C |
+---+ +---+ +---+
I am not sure how to map the UML composition to Ecore
Am I right ?!
Upvotes: 1
Views: 2008
Reputation: 6987
The meaning of your UML is that A can contain many Bs, C contains many Bs, and B can reference 0..1 As and exactly one B.
This UML diagram is incorrect because an instance of B cannot be shared (that is the meaning of composition). So the link B-C should also be 0..1 and in that case you can use containment from both A and C.
Upvotes: 1
Reputation: 33034
An instance of B can exist without being contained in an A, but I'm pretty sure it can not be persisted in that state (using default XML/XMI persistence). In fact, you can get a valid model into this state:
Upvotes: 0
Reputation: 13858
It can be zero, if B is the root of an EMF Resource. An EMF Resource root never has any container. And any EMF model can act as a resource root.
Upvotes: 0