Skip to main content



      Home
Home » Modeling » EMF » limit number (other than 1) of children in an EReference
limit number (other than 1) of children in an EReference [message #423275] Thu, 25 September 2008 14:55 Go to next message
Eclipse UserFriend
Hello,

Is there a way to limit the number (other than 1) of children for an
EReference? I basically have a list in which I would like to limit the
number of children to a maximum of 7.
Setting the lower limit to zero and an upper limit to 1 works fine as
the EMF framework prevents me to add a second child. However, when I
change the upper limit to 7, the EMF framework doesn't prevent me to add
8 or 9 children for example.
Would there be a way to make EMF limit the number of children of an
EReference to a number greater than 1? If so, how would this be possible?

Thanks,

Mircea
Re: limit number (other than 1) of children in an EReference [message #423276 is a reply to message #423275] Thu, 25 September 2008 15:05 Go to previous messageGo to next message
Eclipse UserFriend
Mircea,

Comments below.


Mircea Luchian wrote:
> Hello,
>
> Is there a way to limit the number (other than 1) of children for an
> EReference? I basically have a list in which I would like to limit the
> number of children to a maximum of 7.
> Setting the lower limit to zero and an upper limit to 1 works fine as
> the EMF framework prevents me to add a second child. However, when I
> change the upper limit to 7, the EMF framework doesn't prevent me to
> add 8 or 9 children for example.
The upper bound affects whether you end up with a single value or a list
of values, which imposes some hard limitations, but other than this, the
multiplicity bounds only result in constraint violations that will be
noticed by Diagnostician.INSTANCE.validate, not in hard limits that
can't ever be violated.
> Would there be a way to make EMF limit the number of children of an
> EReference to a number greater than 1? If so, how would this be possible?
Generally it's a bad idea, in my opinion to add hard limits. Obvious if
you set a lower limit like 2, when the list starts empty, it's already
violating this, so you can't expect things never to be in an invalid
state. Also, consider if you want to replace an element in the list.
You might add an element and then remove another element, so forcing the
steps to be done in a different order is not very intuitive. I'd
recommend that you settle for constraints that are diagnosed when
violated rather then trying to enforce them in the model.

Maybe the child creation could be smarter though, but even that's
questionable...
>
> Thanks,
>
> Mircea
Re: limit number (other than 1) of children in an EReference [message #423277 is a reply to message #423276] Thu, 25 September 2008 16:09 Go to previous message
Eclipse UserFriend
Thanks Ed,

It is true that in UML no rules other than 0..1, 0..*, 1 or 1..* exist
and EMF should not be any different. I will perform validation instead.

Mircea

Ed Merks wrote:
> Mircea,
>
> Comments below.
>
>
> Mircea Luchian wrote:
>> Hello,
>>
>> Is there a way to limit the number (other than 1) of children for an
>> EReference? I basically have a list in which I would like to limit
>> the number of children to a maximum of 7.
>> Setting the lower limit to zero and an upper limit to 1 works fine as
>> the EMF framework prevents me to add a second child. However, when I
>> change the upper limit to 7, the EMF framework doesn't prevent me to
>> add 8 or 9 children for example.
> The upper bound affects whether you end up with a single value or a
> list of values, which imposes some hard limitations, but other than
> this, the multiplicity bounds only result in constraint violations
> that will be noticed by Diagnostician.INSTANCE.validate, not in hard
> limits that can't ever be violated.
>> Would there be a way to make EMF limit the number of children of an
>> EReference to a number greater than 1? If so, how would this be
>> possible?
> Generally it's a bad idea, in my opinion to add hard limits. Obvious
> if you set a lower limit like 2, when the list starts empty, it's
> already violating this, so you can't expect things never to be in an
> invalid state. Also, consider if you want to replace an element in
> the list. You might add an element and then remove another element,
> so forcing the steps to be done in a different order is not very
> intuitive. I'd recommend that you settle for constraints that are
> diagnosed when violated rather then trying to enforce them in the model.
>
> Maybe the child creation could be smarter though, but even that's
> questionable...
>>
>> Thanks,
>>
>> Mircea
Previous Topic:Source code for ecore generator
Next Topic:Detecting unresolvable Resources
Goto Forum:
  


Current Time: Wed Jul 09 09:42:44 EDT 2025

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

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

Back to the top