Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Attributes of type EnumSet<E>?
Attributes of type EnumSet<E>? [message #425152] Mon, 17 November 2008 16:20 Go to next message
Andreas Mayer is currently offline Andreas MayerFriend
Messages: 32
Registered: July 2009
Member
In my model, I have several enums that can be combined, for example,
privileges such as READ, WRITE, and DELETE. Therefore, some classes have
multi-valued attributes of such enums.

EMF converts an EEnum into a Java enum, but uses an EList for a
multi-valued enum attribute. I would prefer to use an EnumSet instead.
Aside from the more efficient implementation, EnumSet.equals() ignores
the order in which the values have been added.

Is there a way to force the code generator to use EnumSet instead of
EList here? Are there any plans to add some sp ecial handling for
multi-valued enum attributes?

Andreas
Re: Attributes of type EnumSet<E>? [message #425154 is a reply to message #425152] Mon, 17 November 2008 17:52 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Andreas,

Only Ed can speak to plans, but you can define an EDataType with
java.util.EnumSet as the "instanceTypeName." You can even add the E
generic type parameter (remember to enable Generics in the Ecore Editor
menu).

Then, it's just a matter of implementing the
createFromString/convertToString methods in your generated FactoryImpl
to serialize the enum-set values.

HTH,

Christian

Andreas Mayer wrote:
> In my model, I have several enums that can be combined, for example,
> privileges such as READ, WRITE, and DELETE. Therefore, some classes have
> multi-valued attributes of such enums.
>
> EMF converts an EEnum into a Java enum, but uses an EList for a
> multi-valued enum attribute. I would prefer to use an EnumSet instead.
> Aside from the more efficient implementation, EnumSet.equals() ignores
> the order in which the values have been added.
>
> Is there a way to force the code generator to use EnumSet instead of
> EList here? Are there any plans to add some sp ecial handling for
> multi-valued enum attributes?
>
> Andreas
>
>
>
>
Previous Topic:Re: Dynamic EMF Editor
Next Topic:Implementing Setters for Derived references
Goto Forum:
  


Current Time: Tue Apr 23 12:20:16 GMT 2024

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

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

Back to the top