Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Generating methods for multiple constraints
Generating methods for multiple constraints [message #422326] Sat, 30 August 2008 15:15 Go to next message
Al B is currently offline Al BFriend
Messages: 130
Registered: July 2009
Senior Member
Hi,

I've created a constraint for a single model element via EAnnotation ->
Detail Entry and EMF generates the validation method for it (i.e. the
validateActivityDef_DurationNonempty() method).

Now, if I add a second constraint, then none method for these
constraints are generated in the XYZValidator class. Does it mean that
I can only add one constraint per model element?

/**
* Initializes the annotations for
<b>http://www.eclipse.org/emf/2002/Ecore</b>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void createEcoreAnnotations() {
String source = "http://www.eclipse.org/emf/2002/Ecore";
addAnnotation
(activityDefEClass,
source,
new String[] {
"constraint_1", "DurationNonempty",
"constraint_2", "ClaimsConflict"
}); }
Re: Generating methods for multiple constraints [message #422327 is a reply to message #422326] Sat, 30 August 2008 15:59 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, AJ,

To specify multiple constraints, you should define only one annotation
key with all of the constranint, thus:

EAnnotation http://www.eclipse.org/emf/2002/Ecore
constraints -> DurationNonEmpty ClaimsConflict

The package-impl code would end up looking like:

protected void createEcoreAnnotations() {
String source =
"http://www.eclipse.org/emf/2002/Ecore";
addAnnotation
(activityDefEClass,
source,
new String[] {
"constraints", "DurationNonempty ClaimsConflict"
});
}


HTH,

Christian

AJ wrote:
> Hi,
>
> I've created a constraint for a single model element via EAnnotation ->
> Detail Entry and EMF generates the validation method for it (i.e. the
> validateActivityDef_DurationNonempty() method).
>
> Now, if I add a second constraint, then none method for these
> constraints are generated in the XYZValidator class. Does it mean that
> I can only add one constraint per model element?
>
> /**
> * Initializes the annotations for
> <b>http://www.eclipse.org/emf/2002/Ecore</b>.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> protected void createEcoreAnnotations() {
> String source =
> "http://www.eclipse.org/emf/2002/Ecore";
> addAnnotation
> (activityDefEClass,
> source,
> new String[] {
> "constraint_1", "DurationNonempty",
> "constraint_2", "ClaimsConflict"
> }); }
Previous Topic:namespaceURI retrieval
Next Topic:Getting a list of all Namespace URIs, including that of cross referenced packages
Goto Forum:
  


Current Time: Sun May 12 09:39:47 GMT 2024

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

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

Back to the top