Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Specifying enum operations in xcore
Specifying enum operations in xcore [message #1140254] Wed, 16 October 2013 08:21 Go to next message
Varghese Cottagiri is currently offline Varghese CottagiriFriend
Messages: 2
Registered: October 2013
Junior Member
Is this the right way to specify operations in xcore?
Getting a syntax error at line 12, "mismatched input 'op' expecting '}'".
enum DaysInWeek{
    MON
    TUE
    WED
    THU
    FRI
    SAT
    SUN
    
--> op boolean isWeekend(DaysInWeek daysInWeek) {
        switch(daysInWeek){
            case SAT, SUN:
                return true
             default:
                return false            
        }
    }
}

In ecore/genmodel - one would add methods to the generated enum file without the @Generated annotation.

Is there a bug in my syntax or is it something that xcore does not support currently?

Thanks for the help
Varghese C V
Re: Specifying enum operations in xcore [message #1140597 is a reply to message #1140254] Wed, 16 October 2013 13:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
You can't specify operations for enumerations. Not only doesn't Xcore
support it, but neither does Ecore and that's what ultimately drives the
generator...

On 16/10/2013 2:48 PM, Varghese Cottagiri wrote:
> Is this the right way to specify operations in xcore?
> Getting a syntax error at line 12, "mismatched input 'op' expecting '}'".
>
> enum DaysInWeek{
> MON
> TUE
> WED
> THU
> FRI
> SAT
> SUN
> --> op boolean isWeekend(DaysInWeek daysInWeek) {
> switch(daysInWeek){
> case SAT, SUN:
> return true
> default:
> return false }
> }
> }
>
> In ecore/genmodel - one would add methods to the generated enum file
> without the @Generated annotation.
>
> Is there a bug in my syntax or is it something that xcore does not
> support currently?
>
> Thanks for the help
> Varghese C V


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Specifying enum operations in xcore [message #1140898 is a reply to message #1140254] Wed, 16 October 2013 17:44 Go to previous message
Varghese Cottagiri is currently offline Varghese CottagiriFriend
Messages: 2
Registered: October 2013
Junior Member
Thank you Ed, for the clarification. I will have to continue to keep these methods in the generated code.
Previous Topic:Generated eBaseStructuralFeatureID issue
Next Topic:saveModel deletes the model
Goto Forum:
  


Current Time: Thu Apr 25 03:42:27 GMT 2024

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

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

Back to the top