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
- Containment reference from A to B, upperbound: -1
- Opposite reference B to A, lowerbound 0, upperbound 1
- Containment reference from C to B, upperbound: -1
- Opposite reference B to C, lowerbound = uperbound = 1
Am I right ?!
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.