|Re: Map keys shall be only attributes of an EClass [message #1052985 is a reply to message #1052965]
||Wed, 01 May 2013 17:25
| Ed Merks
Registered: July 2009
On 01/05/2013 5:31 PM, John M. wrote:
> I have a class X, which contains different attributes for describing
> base values.
> Now I want to describe effects on these attributes.
> My idea was to use an EMap, but I don't want to use a string as key to
> prevent a check if the method is really existing before calling a
I'm not sure what you mean by this sentence.
> I was thinking about the attribute reference, but I don't know how to
> model it with Ecore that it allows only available attributes as keys.
EReference.eKeys has nothing to do with EMaps...
> Another idea would be the implementation over an own EClass, which
> contains a key and the value, but I don't know how to reference on the
> EAttribute either.
That's what EMaps do, e.g., look at EStringToStringMapEntry in Ecore.
> Another option would be the implementation of a constraint, but I
> hoped there is perhaps a better way to do that.
|Re: Map keys shall be only attributes of an EClass [message #1053133 is a reply to message #1052992]
||Thu, 02 May 2013 15:27
|| Christian W. Damus
Registered: July 2009
Are you looking for a map entry in which the key references an
EAttribute from your Ecore model? I think you would just create an
EClass named, say, EAttributeToStringMapEntry with
- an EReference named "key" having EType = EAttribute
- an EAttribute named "value" having EType = EString
- implementationClassName = "java.util.Map$Entry"
the value could be an EReference of any type, if that's what you need.
Then, a containment EReference of this EAttributeToStringMapEntry type
will generate an EMap of the kind you need (I think).
I think the Ecore editor should give you EAttribute in the list of
possible eTypes for the key reference, but if it doesn't, then you can
load the Ecore model using the "Load Resource..." action in the
editor's context menu.
To constrain the keys to be EAttributes only some some particular
EClass, you can customize the getChoiceOfValues() method in the
item-provider generated for your map-entry EClass such that it only
provides the EAttributes that you want the user to be able to choose
On 2013-05-01 18:38:40 +0000, John M. said:
> Hello Ed,
> Thanks for your fast answer.
> I am searching for a method to have a map which keys are the
> Eattributes of a given EClass.
Powered by FUDForum
. Page generated in 0.02256 seconds