eclipse-emfupperbound

EMF Upper Bound does not restrict the list


I am getting started with EMF and have completed the EMF tutorial. So far I think I understood the concept. However, I have a class "League" which has a attribute "players" which is a list of Players. I can use the lower and upper bound to restrict the bounds of this list. Lets say I want a league never to have more than 18 Players. I thought setting the upper bound to 18 would do the job. But it does not. I expected the program to throw an exception or not add any more players, when I add more than 18 players.

Or did I understand the upper/lower bounds wrong?


Solution

  • EMF will not throw an exception but it will report a validation error if you validate the root EObject of your model (Resource) using Diagnostician.INSTANCE.validate(yourRootEObject).