Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to achieve selecting impl of interface
How to achieve selecting impl of interface [message #1618807] Mon, 16 February 2015 06:20 Go to next message
Anton Hughes is currently offline Anton HughesFriend
Messages: 66
Registered: January 2013
Member
Hi

I am trying to achieve the following.
Using xcore, I would like have the possiblity of dynamically selecting which implementation of an interface to use. So, if I was using the Dynamic Instance, when adding a Child to the family, I would be able to choose if it is a Boy or a Girl.

The following is just a simple example to demonstrate what I am trying to achieve.

package sample

class Family{
	String father
	String mother
	container Child[] children opposite family
}

interface Child{
	
	
}
class Boy extends Child{
	container Family family opposite children
	String name	
}
class Girl extends Child{
	container Family family opposite children
	String name		
}


Can anyone recommend how to do this?

Thanks and regards
Re: How to achieve selecting impl of interface [message #1619013 is a reply to message #1618807] Mon, 16 February 2015 09:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30132
Registered: July 2009
Senior Member
Anton,

Isn't what you describe that you want exactly what you already get?

On 16.02.2015 07:20, Anton Hughes wrote:
> Hi
>
> I am trying to achieve the following. Using xcore, I would like have the
> possiblity of dynamically selecting which implementation of an interface
> to use. So, if I was using the Dynamic Instance, when adding a Child to
> the family, I would be able to choose if it is a Boy or a Girl.
>
> The following is just a simple example to demonstrate what I am trying
> to achieve.
>
>
> package sample
>
> class Family{
> String father
> String mother
> container Child[] children opposite family
> }
>
> interface Child{
>
>
> }
> class Boy extends Child{
> container Family family opposite children
> String name
> }
> class Girl extends Child{
> container Family family opposite children
> String name
> }
>
>
> Can anyone recommend how to do this?
>
> Thanks and regards
Re: How to achieve selecting impl of interface [message #1619038 is a reply to message #1619013] Mon, 16 February 2015 09:43 Go to previous messageGo to next message
Anton Hughes is currently offline Anton HughesFriend
Messages: 66
Registered: January 2013
Member
Ed Merks wrote on Mon, 16 February 2015 09:25
Anton,

Isn't what you describe that you want exactly what you already get?



Hi Ed
Thanks for the reply.
I wish it was! Alas, I am certainly missing something - though I do not know what.
I am getting the following errors:
Quote:
'Couldn't resolve reference to GenFeature 'family'.'

And
Quote:
'The opposite of the opposite may not be a reference different from this one'

Re: How to achieve selecting impl of interface [message #1619178 is a reply to message #1619038] Mon, 16 February 2015 11:40 Go to previous message
Anton Hughes is currently offline Anton HughesFriend
Messages: 66
Registered: January 2013
Member
I received the answer via another, very helpful, source:

class Family{
	String father
	String mother
	container Child[] children opposite family
}

interface Child{
	container Family family opposite children
}
class Boy extends Child{
	String name	
}
class Girl extends Child{
	String name		
}
Previous Topic:[Xcore] Declaring (in op) a local variable of generic type
Next Topic:How to convert a URI to another URI format
Goto Forum:
  


Current Time: Tue May 21 07:03:06 GMT 2019

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

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

Back to the top