|
Re: [MOFScript] How to specify an enumeration literal in an expression? [message #62612 is a reply to message #62588] |
Thu, 18 June 2009 11:59 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Toñi Reina![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=reinaqu%40lsi.us.es) Messages: 209 Registered: July 2009 |
Senior Member |
|
|
I have just found that literals in enumerations are treated as Strings,
so the expression has to be the following one:
if (self.field = "VALUE_A"){
//do something
}
Toñi Reina Quintero escribió:
> Hi all,
>
> I really don't know if this is the best group to post this question,
> but since the closing of the eclipse.modelling.gmt, I don't know which
> is the best group for posting it. I apologise in advance, in case this
> is not the right group.
>
> My problem is to find the right syntax for writing an expression in
> which an enumeration is involved. Let's suppose you have the following
> piece of metamodel described by means of KM3:
>
> class ClassA {
> attribute field: FieldType;
> };
> enum FieldType {
> literal VALUE_A;
> literal VALUE_B;
> literal VALUE_C;
> };
>
> I'm trying to write a MOFScript rule to test the value stored in the
> attribute field, writing something similiar to this piece of code:
>
> metamodel.Class::method(){
>
> if (self.field = VALUE_A){
> //do something
> }
> }
>
> But MOFScript does not recognize the literal VALUE_A. I also have tried
> to change VALUE_A for FieldType.VALUE_A, but it doesn't work either.
>
> The only way I have found for not having compilation errors, is the
> following:
>
> if (self.field = 0){
> //do something
> }
>
> Does anybody know how to use the literals instead of the stored values
> in an enumeration?
>
> Thanks,
> Toñi Reina
|
|
|
Powered by
FUDForum. Page generated in 1.07062 seconds