In Eclipse, I'm trying to add a List to my EMF Model. In .ecore model:
But when i try to open the genmodel of this model, appears an error saying: "The attribute 'MyClass.MyList' is not transient so it must have a data type that is serializable".
What am i doing wrong?
Thanks in advance.
You do not have to 'manually' deal with it being a list.
Remember, you are using UML.
A List is merely an ordered association to a type, in which the upper bound is set to *.
Therefore, simply add MyList
to MyClass
, set its multiplicity to 0..-1 (by setting its upper bound to -1, which means * in EMF) and ensure the association's Ordered
property is set to True (otherwise you would get a Set). Also set its type to EString.
Here is an example, in which a DFA
has a list of the type State
, in accordance with the above instructions. I also set "containment" to true, as to make the list hold a strong reference the objects it contains (this has to do with memory management, I would suggest you to do the same). Note that I've set the type to State, as this is a list of State objects.