Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Do bounds (lower and upper) of EReference have any effect?(I can add any count of objects to a Elist although multiplicity was limited)
Do bounds (lower and upper) of EReference have any effect? [message #552477] Thu, 12 August 2010 10:54 Go to next message
Oleg Bolshakov is currently offline Oleg BolshakovFriend
Messages: 36
Registered: August 2010
Member
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?

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);

<...>
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 Go to previous message
Ed Merks is currently offline Ed MerksFriend
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/
Previous Topic:[CDO] Cross references and xmi serialization
Next Topic:Transformaing a CMOF model to an ECore model
Goto Forum:
  


Current Time: Tue Apr 23 11:18:11 GMT 2024

Powered by FUDForum. Page generated in 0.03079 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top