Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Force serialization of equal values?
Force serialization of equal values? [message #1182775] Tue, 12 November 2013 12:05 Go to next message
Jens Rabe is currently offline Jens RabeFriend
Messages: 53
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 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4154
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 Go to previous messageGo to next message
Jens Rabe is currently offline Jens RabeFriend
Messages: 53
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

Re: Force serialization of equal values? [message #1200652 is a reply to message #1198662] Thu, 21 November 2013 10:40 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4154
Registered: July 2009
Senior Member
Hi

I don't think you'll need ExtendedMetaData. You should find that setting
XMLResource.OPTION_KEEP_DEFAULT_CONTENT true in your save options map
should be enough.

Regards

Ed Willink

On 20/11/2013 12:47, Jens Rabe wrote:
> 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()?
Previous Topic:Problem running GMFTools with Xtext/GMF integration
Next Topic:[Xtext 2.4.1] Resolve cross references without 'name' in target file
Goto Forum:
  


Current Time: Thu Nov 27 22:30:57 GMT 2014

Powered by FUDForum. Page generated in 0.01795 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software