Force serialization of equal values? [message #1182775] |
Tue, 12 November 2013 12:05 |
Jens Rabe Messages: 81 Registered: September 2013 |
Member |
|
|
Is it possible to force serialization of equal values? In our project, we have a datatype which has a value and a unit, and converting it to another unit causes the object to still be equal as of equals(), i.e., having such an object which denotes a length of 1m and converting it to 1000mm causes the new object containing 1000mm to be equal to the 1m one as of equals().
Now, we change the model at different locations, not only in the Xtext editor. Saving such a changed object now causes the default ValueSerializer to check if the new value (1000mm) is equals() to the old one (1m) which returns true - and the serializer returns the old value of 1m, causing this portion of the serialization to not get updated.
This length object is no EObject, it is used as an EDataType in an EAttribute so I have no control over it in the grammar.
Is it possible to force serialization of all objects even if they are equals() to their old one, or do I have to change the implementation of the equality mechanism of the lengths?
|
|
|
Re: Force serialization of equal values? [message #1182829 is a reply to message #1182775] |
Tue, 12 November 2013 12:46 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
If you use a non-auto-generated model you can start playing games with
ExtendedMetaData.
But It seems like you are getting an early warning that you have a
design problem. Better to fix the design than have over elaborate
implementation workarounds.
It is very dangerous to have a DataType whose equals is in any way
suspect. Just wait till you start creating Sets.
Regards
Ed Willink
On 12/11/2013 12:05, Jens Rabe wrote:
> Is it possible to force serialization of equal values? In our project,
> we have a datatype which has a value and a unit, and converting it to
> another unit causes the object to still be equal as of equals(), i.e.,
> having such an object which denotes a length of 1m and converting it
> to 1000mm causes the new object containing 1000mm to be equal to the
> 1m one as of equals().
> Now, we change the model at different locations, not only in the Xtext
> editor. Saving such a changed object now causes the default
> ValueSerializer to check if the new value (1000mm) is equals() to the
> old one (1m) which returns true - and the serializer returns the old
> value of 1m, causing this portion of the serialization to not get
> updated.
> This length object is no EObject, it is used as an EDataType in an
> EAttribute so I have no control over it in the grammar.
>
> Is it possible to force serialization of all objects even if they are
> equals() to their old one, or do I have to change the implementation
> of the equality mechanism of the lengths?
|
|
|
Re: Force serialization of equal values? [message #1198662 is a reply to message #1182829] |
Wed, 20 November 2013 12:46 |
Jens Rabe Messages: 81 Registered: September 2013 |
Member |
|
|
We need this equality mechanism in our project because we rely on these side effects (i.e. a set where we add 1m and 1000mm has to only contain 1m and not 1000mm). Only at this point, a different value which is equal as per equals() is to be saved.
Can you explain how to use the ExtendedMetaData so that the serializer is forced to serialize the new value when I change it, but it remains equals()?
[Updated on: Wed, 20 November 2013 14:08] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02670 seconds