|
Re: Do bounds (lower and upper) of EReference have any effect? [message #552567 is a reply to message #552477] |
Thu, 12 August 2010 16:07 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Comments below
Rrock wrote:
> There two classes (Class1 and Class2) and EReferences between them in
> EMF model (,ecore file). EReferences multyplicity's are 0..* for src
> role and 0..3 for dst role. I can see two ELists created for each
> class but I can add any count of objects to any of the lists. The
> question is - is there a realisation of EReference's bounds (for
> example upper bound) and why doesn't it have any effect in my Java code?
Only the upper bound has a direct affect on the generated model; if it's
bigger than 1, you end up with a list instead of a single value.
Anything else just acts as a constraint that's checked when you invoke
the validator. E.g. Diagnostician.INSTANCE.validate.
>
> Here is the code:
>
> Package1.impl.Package1FactoryImpl.init();
>
> Package1.meta.Package1Factory factory =
> Package1.meta.Package1Factory.eINSTANCE;
>
> Class1 object1 = factory.createClass1();
> object1.setName1("object1");
>
> Class2 object2 = factory.createClass2();
> object2.setName2("object2");
>
> <...>
>
> EList<Class1> dests = object2.getDst();
> dests.add(object1);
> dests.add(object7);
> dests.add(object8);
> dests.add(object9);
> dests.add(object10);
> dests.add(object11);
> dests.add(object12);
>
> <...>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03079 seconds