Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to force generation of Validator((without defining a constraint or an invariant))
How to force generation of Validator [message #901441] Sun, 12 August 2012 12:02 Go to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Hello,

is it possible to force the generation of the *.util.*Validator without defining a constraint or an invariant in the model? The purpose would be to validate simple restrictions, such as the bounds of a feature.

For example using this model:
class MyElement {
	String[1] name
}

I would like to do something like this:
MyElement element = MyFactory.eINSTANCE.createMyElement();
Diagnostic diagnostic = Diagnostician.INSTANCE.validate(element);
Assert.isTrue(diagnostic.getSeverity() == Diagnostic.ERROR);

Greetings
Christoph
Re: How to force generation of Validator [message #901445 is a reply to message #901441] Sun, 12 August 2012 12:57 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Christoph,

Comments below.

On 12/08/2012 2:02 PM, Christoph Keimel wrote:
> Hello,
>
> is it possible to force the generation of the *.util.*Validator
> without defining a constraint or an invariant in the model?
No. An important aspect of the validator is to dispatch to all the
constraints at most once, even in the face of multiple inheritance.
> The purpose would be to validate simple restrictions, such as the
> bounds of a feature.
EObjectValidator will enforce those. Diagnostician.INSTANCE can be used
to dispatch to whatever validator is available, either the base
EObjectValidator, or the registered generated validator.
>
> For example using this model:
> class MyElement {
> String[1] name
> }
> I would like to do something like this:
> MyElement element = MyFactory.eINSTANCE.createMyElement();
> Diagnostic diagnostic = Diagnostician.INSTANCE.validate(element);
> Assert.isTrue(diagnostic.getSeverity() == Diagnostic.ERROR);
That should already work.
> Greetings
> Christoph


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to force generation of Validator [message #901462 is a reply to message #901445] Sun, 12 August 2012 18:14 Go to previous message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Hi Ed

Thanks for the insight! It work's just like you say.
(And it would have all along if I hadn't gotten mixed up with all my temporary tests. Time to clean up! Wink)

Smile,
Christoph
Previous Topic:[Xcore] Imposing constraints on Xcore model
Next Topic:[Teneo] @PrePersist/PreUpdate - Hibernate Interceptors - extension manager
Goto Forum:
  


Current Time: Fri Mar 29 04:43:30 GMT 2024

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

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

Back to the top