Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Xcore] wrapping an existing enum
[Xcore] wrapping an existing enum [message #1776541] Fri, 17 November 2017 13:32 Go to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I try to realize an implementation of an existing API with Xcore. In addition to interfaces, this API has also a classic enumeration.

Take this example:
package existing.api;

public enum Rating {

I was hoping to be able to do something like this in Ecore:
package simple.model
interface Rating wraps existing.api.Rating {}

class Book {
    String name
    Rating rating

But this doesn't seem to work. It generates an error in the Switch class.
In my example in: simple.model.util.ModelSwitch.doSwitch(int, EObject):

protected T doSwitch(int classifierID, EObject theEObject) {
    switch (classifierID) {
        case ModelPackage.RATING: {
            Rating rating = (Rating)theEObject; //compiler Error: Cannot cast from EObject to Rating
            T result = caseRating(rating);
            if (result == null) result = defaultCase(theEObject);
            return result;

Any Idea what I can do?

Thank you in advance.
Re: [Xcore] wrapping an existing enum [message #1776550 is a reply to message #1776541] Fri, 17 November 2017 15:27 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31781
Registered: July 2009
Senior Member
It doesn't make sense to wrap something that isn't a Java interface as an Xcore interface. Also, if you want to use the classifier to define a non-transient attribute's type, you need to use a data type, not a class/interface. There is no support for wrapping an existing enum as anything another than a data type. I.e., an EEnum/xEnum can't be a wrapper. So you can use "type Foo wraps A.b.c" and you can define the create/convert operations in the type definition. Ctrl-Space is your friend.

Ed Merks
Professional Support:
Previous Topic:[CDO] Exception when switching to Oxygen
Next Topic:Exception when resolving Cross References
Goto Forum:

Current Time: Mon Mar 08 17:17:41 GMT 2021

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

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

Back to the top