|'static' variables for EVL invariants [message #589646]
||Tue, 01 June 2010 15:50
| Endre Balogh
Registered: May 2010
I'm trying to create the following invariant for my model: I have an abstract class NamedElement with several concrete subclasses. I want them all to have their names defined (check : self.name.isDefined()). I also want to provide a quick fix that assigns default names to unnamed instances, such as for the class Entity, the unnamed objects will be called Entity1, Entity2, etc.
I ran into two problems:
Is it possible to persist a variable's value between calls to the invariant? The purpose would be to keep a counter when renaming objects, although this isn't a very good solution, since I can't keep a different counter for all subclasses, i.e. the unnamed instances would be named Entity1, Package2, Package3, Entity4 etc.
How can I reach all instances of the subclass I'm checking? I can't use the invariant's context, since that is the abstract parent class. I tried combinations of self.eClass() and self.type() with .all, .allInstances and .allOfType, but no methods/properties with these name could be found. Getting that list would allow me to count how many objects of that type have their name set to their class name concatenated with a number.
Response to any of the two questions would be appreciated, as well as other indications in case I took a completely wrong approach, or if you have a simpler solution to my problem.
Powered by FUDForum
. Page generated in 0.02029 seconds