Difference in treating redfinded properties [message #627081] |
Fri, 24 October 2008 13:05 |
Eclipse User |
|
|
|
Originally posted by: florianwendland.freenet.de
Hey again,
after being happy to understand and to apply the Union/Subsets-mechanism to
an EMF-model, i was playing a little bit with the Redefinition mechanism.
I've explored two different behaviors, that depend on the cardinality of the
redefined element, and i don't know, whether this behavior is correct.
Let's display an example:
A : Element
+ refB : B [0..*]
A2 : A
+refBB : BB[1]
B:Element
BB:Element
In this constellation, the class A2Impl gets an Operation like getRefB()
that return an UnmodifiableEList. In the Editor, it is not possible to add
an element into this list. This is of course the correct behavior, the
reference refB was redefined in A2 to ref BB and therefore the property refB
logically didn't exist in class A2. Physically it is not possible to remove
an attribute by inheritance.
But if i change the model of A2 to this one
A2 : A
+refBB : BB [0..*]
the gefRefBBs() method looks like this:
@Override
public EList<C> getRefToBs() {
@SuppressWarnings("unchecked")
EList<BB> redefToBB = (EList<BB>)((EList<?>)getRedefToBBs());
return refBB;
}
and it is possible to add an element BB to the redefined property. In fact,
the result will be pushed back into the redfined list refBBs, but i would
expect, that accessing an redefined property by adding something, would
cause everytime an exception. As is mentioned, logically, the redefined
property from the parent class doesn't exist in the subclass, or am I
wrong???
Hope i expressed my question clearly.
Marc-Florian
|
|
|
Powered by
FUDForum. Page generated in 0.04022 seconds