Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Xcore] Basic Question(Setting a default value for a extended attribute)
[Xcore] Basic Question [message #1433836] Mon, 29 September 2014 09:54 Go to next message
João Bastos is currently offline João BastosFriend
Messages: 9
Registered: September 2014
Junior Member
Hi again,

Sorry again for the type of questions.
Answer only if you have the time and patience!

I have the following:

class Window
{
String color
}

And I would like to define sub-classes with pre-defined default values.
Is this possible?

I tried doing it in several ways, like bellow.
But either it says the classifier is missing, or if I repeat the attribute it obviously says they cannot have the same name.

class BlackWindow extends Window
{
color = "black"
}

Thank you in advance,
João Bastos
Re: [Xcore] Basic Question [message #1433903 is a reply to message #1433836] Mon, 29 September 2014 11:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30351
Registered: July 2009
Senior Member
João,

Comments below.

On 29/09/2014 11:54 AM, João Bastos wrote:
> Hi again,
>
> Sorry again for the type of questions.
> Answer only if you have the time and patience!
>
> I have the following:
>
> class Window
> {
> String color
> }
>
> And I would like to define sub-classes with pre-defined default values.
> Is this possible?
No, it's not possible in Ecore so therefore it's not possible in Xcore.
>
> I tried doing it in several ways, like bellow.
> But either it says the classifier is missing, or if I repeat the
> attribute it obviously says they cannot have the same name.
>
> class BlackWindow extends Window
> {
> color = "black"
> }
>
> Thank you in advance,
> João Bastos
Re: [Xcore] Basic Question [message #1437724 is a reply to message #1433836] Sat, 04 October 2014 22:56 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 671
Registered: July 2009
Location: Trondheim, Norway
Senior Member
João,

The way to do this is to make the subclasses define/implement the
operation getColor that returns the constant value if the color
attribute isn't already set.

Hallvard

On 29.09.14 11:54, João Bastos wrote:
> Hi again,
>
> Sorry again for the type of questions.
> Answer only if you have the time and patience!
>
> I have the following:
>
> class Window
> {
> String color
> }
>
> And I would like to define sub-classes with pre-defined default values.
> Is this possible?
>
> I tried doing it in several ways, like bellow.
> But either it says the classifier is missing, or if I repeat the
> attribute it obviously says they cannot have the same name.
>
> class BlackWindow extends Window
> {
> color = "black"
> }
>
> Thank you in advance,
> João Bastos
Re: [Xcore] Basic Question [message #1438779 is a reply to message #1437724] Mon, 06 October 2014 13:25 Go to previous message
João Bastos is currently offline João BastosFriend
Messages: 9
Registered: September 2014
Junior Member
Ok, thank you so much for both of your replies!

Kind Regards,
João Bastos
Previous Topic:Load ecore metamodel in eclipse runtime
Next Topic:How to load EClasses of a certain subtype
Goto Forum:
  


Current Time: Sun Aug 18 23:51:14 GMT 2019

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

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

Back to the top