|
|
|
Re: Change class of a given EObject [message #755179 is a reply to message #755126] |
Mon, 07 November 2011 15:38 |
Ed Merks Messages: 33145 Registered: July 2009 |
Senior Member |
|
|
Hauke,
Comments below.
On 07/11/2011 2:25 PM, Hauke Fuhrmann wrote:
> Hi there,
>
> is there any practical way to change the class of a given EObject to a
> subclass of that object?
No.
>
> e.g. I have a class "Person" and subclasses "Man" and "Woman".
>
> For some reason I have an instance "Foo" of "Person", yet not knowing
> the gender. Later I get the information that "Foo" is male but my
> model has no gender attribute but uses subclasses for the gender.
>
> Is there a way to "upgrade" the class of Foo from Person to Man?
No.
>
> A workaround would be to create a new Man, copy all attributes and
> replace it in the containment hierarchy of Foo. However, there might
> be cross-references to Foo which I also would need to switch to the
> new Man instance.
> Is there a good way to find all foreign references to Foo so I can
> switch them to the new instance?
EcoreUtil has UsageCrossReferencer. You could look at DeleteCommand to
see how it's used.
>
> Rationale: I encounter quite often MM that code information in
> subclasses rather than in attributes. This is nice for using
> polymorphism, but bad for changing the objects as discussed above.
>
> Any hint how to handle that?
>
> Cheers,
> Hauke
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03733 seconds