|Re: Array of references in model [message #1405151 is a reply to message #1405095]
||Wed, 06 August 2014 17:59
| Ed Merks
Registered: July 2009
On 06/08/2014 5:20 PM, Mauro Condarelli wrote:
> I need to model a (short) array of references in one of my classes.
Model and array are kind of mutually exclusive...
> AFAIK these are implemented using ELists in EMF.
> Problem is I need to keep track of element order *AND* I may have
> multiple NULL entries.
Yes, you can't have nulls in EObject ELists.
> Is this supported?
> I tried setting nullable
Nullable? What's that?
> and !unique in ecore, but I see malfunctioning (apparently iterations
> stop at first null found).
> For very short arrays I used multiple references, but that rapidly
> becomes impractical when array lenght grows above a handful elements.
> What is the right way to do this?
You can't model an array of references and you can't have nulls, nor
even duplicates, in EObject ELists. Presumably you want some type of
cross reference. The best I can suggest is to model a containment
reference of place holder objects that in turn hold the references. You
could provide an operation that returns the list of references and
implement that list so it's mutable, i.e., it's effectively derived from
the list of placeholder objects so any modification to the list is a
modification of the underlying placeholder list, i.e., something like we
Ecore itself does for eSuperTypes which is derived from
eGenericSuperTypes, but is also directly modifiable, but keep in mind
that you ought not define a derived reference because nothing in the
framework will be happy to find null in a reference list...
Powered by FUDForum
. Page generated in 0.02072 seconds