Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [xcore] derived feature does not allow class types
[xcore] derived feature does not allow class types [message #1736516] Thu, 30 June 2016 06:01 Go to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
I have an xcore file with the following classes:
class Information {
String sName
String birthday
String age
}

class Directory {
String name
String address
derived Information xInfo get {
  //call the get method here that will return a type Information
}
}


But I am getting this error:
The generic attribute type must not refer to a class

How can I use the derived feature with a class?

[Updated on: Thu, 30 June 2016 08:54]

Report message to a moderator

Re: [xcore] value is not stored when set via xtend [message #1736569 is a reply to message #1736516] Thu, 30 June 2016 11:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Chris,

Comments below.


On 30.06.2016 02:01, chris yo wrote:
> I have an xcore file with the following classes:
>
> class Information {
> String sName
> String birthday
> String age
> }
>
> class Directory {
> String name
> String address
> contains Information xInfo
> }
>
>
> The xInfo variable is populated during validation.
Modifying the model during validation doesn't sound appropriate. That's
probably operating on a model that's loaded and then discarded.
> So, I have an xtend method that sets this.
>
> public static val aDirs = new ArrayList<Directory>
> public static val aInfo = new ArrayList<Information>
>
> def public setInfo()
> {
> for (m: aDirs)
> {
> val x = aInfo.findFirst[m.name.equals(SName)]
> if (x != null)
> m.xInfo = x //print also shows that this is correctly set.
> }
> }
>
> def public printInfo()
> {
> for (m: aDirs)
> {
> if (m.xInfo == null) // check if null, this returns true.
> {
> // do nothing
> }
> }
> }
>
>
>
> With the two methods above, I called setInfo() and then printInfo(),
> but in printInfo(), xInfo variable is null again.
>
> aDirs and aInfos are populated during transform.
>
>
> What am I doing wrong?
Best you set a breakpoint and debug it. I can't guess what might be
missing.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [xcore] value is not stored when set via xtend [message #1736645 is a reply to message #1736569] Thu, 30 June 2016 18:24 Go to previous messageGo to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
Hi Ed,

I tried to change the contents of the xcore class to a derived feature but somehow, it is throwing me an error.
"The generic attribute type must not refer to a class".

Is it possible to use the derived feature like this:
derived Information xInfo get {
return MyVariables::aInfo.findFirst[name.equals(SName)]
}
Re: [xcore] value is not stored when set via xtend [message #1736651 is a reply to message #1736645] Thu, 30 June 2016 21:48 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Chris,

Yes, but Information is a class so the feature needs to be a reference
(using the refers keyword).


On 30.06.2016 14:24, chris yo wrote:
> Hi Ed,
>
> I tried to change the contents of the xcore class to a derived feature
> but somehow, it is throwing me an error.
> "The generic attribute type must not refer to a class".
>
> Is it possible to use the derived feature like this:
> derived Information xInfo get {
> return MyVariables::aInfo.findFirst[name.equals(SName)]
> }
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Managing dependencies between EMF resources.
Next Topic:[xcore] How to set a class type variable
Goto Forum:
  


Current Time: Thu Apr 25 01:59:05 GMT 2024

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

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

Back to the top