Unset on isMany containment-ref doesn't trigger detachment [message #1075325] |
Mon, 29 July 2013 04:38  |
Eclipse User |
|
|
|
Calling unSet on a single-valued containment ref triggers detachment. Calling unSet on a many-valued containment ref does not, leaving the previously-referenced objects in limbo.
Why the difference?
Thanks
--
Caspar
[Updated on: Mon, 29 July 2013 04:40] by Moderator
|
|
|
|
|
|
|
Re: Unset on isMany ref does not trigger detachment [message #1076389 is a reply to message #1076373] |
Wed, 31 July 2013 05:51   |
Eclipse User |
|
|
|
Caspar,
Comments below.
On 31/07/2013 11:17 AM, Caspar De Groot wrote:
> [quote title=Ed Merks wrote on Mon, 29 July 2013 06:51]
>
>>> Your point about the *generated* eUnset made me realize
>>> I have none;
>
>> Reflective delegation?
>
> Yes.
>
>> Unsettable just means there's an extra state to distinguish having
>> just the default value as opposed to having been explicitly set to a
>> value that happens to be the same as the default value.
>
> So this distinction only affects the return value of the isSet
> method? It has no bearing on eUnset at all?
Yes.
>
> But then if a feature has unsettable=false, what is the correct
> isSet behavior? To always return true? Or is isSet undefined for
> features that have unsettable=false?
In general there are the following expectations.
* When you first create an EObject x, x.eIsSet(f) will be false for
each f in x.eClass().getEAllStructuralFeatures().
* After you call x.eUnset(f), x.eIsSet(f) will be false.
* After you call x.eSet(f, value), the value of x.eIsSet(f) depends on
whether f is an unsettable feature. If f is unsettable then it will
be true, if f is not unsettable, then it will be the same as testing
(value == null ? f.getDefaultValue() == null ?
value.equals(f.getDefaultValue()).
So the difference between unsettable features and non-unsettable
features is that for unsettable features there is one more state than
can be represented with only the values of the type. You'll see in
generated models, that's an extra boolean or an extra bit flag, in
dynamic/reflective models in the settings array, it's a special marker
value not from the data type. So unsettable features are always eIsSet
true after a call to eSet and false after a call to eUnset. For normal
(non unsettable features), eIsSet depends purely on whether the current
value of the feature is equal to the default value for the feature, so
calling eSet or eUnset will not change the state if you set to a value
equal to the default, or unset when it already had the default value.
>
>> It doesn't mean what you assumed.
>
> That's for sure ;)
> Thanks again.
>
> --
> Caspar
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.04988 seconds