Chapter 18. The Validation Framework

One problem we have not yet addressed is how we can define what constitutes a valid state for objects modeled in EMF. As we will see in this chapter, you can declare, right in your model, constraints and invariants to be verified when a validation is performed against the instances of your classes. Also, we’ll detail how the code generated by EMF is affected by these new elements and how you can invoke validation either from your code or through the generated editors.

18.1 Constraints and Invariants

EMF’s notion of constraints and invariants is inspired by their definition in UML. There, a constraint is a statement that must be valid at some point in time, whereas an invariant is an assertion that should always ...

Get EMF: Eclipse Modeling Framework Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.