Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Defining which derived class a feature from an abstract class shall use
Defining which derived class a feature from an abstract class shall use [message #938932] Wed, 10 October 2012 09:31 Go to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
Hello,

I have an abstract class A with a Reference called definition, its EType is an abstract class B too.
Now I have a class which extends A and I want to set, that definition must be C, which extends class B.

Is there such a possibility or is there perhaps a "work-around"?
Re: Defining which derived class a feature from an abstract class shall use [message #938971 is a reply to message #938932] Wed, 10 October 2012 10:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
John,

Comments below.

On 10/10/2012 11:31 AM, John M. wrote:
> Hello,
>
> I have an abstract class A with a Reference called definition, its
> EType is an abstract class B too.
> Now I have a class which extends A and I want to set, that definition
> must be C, which extends class B.
>
> Is there such a possibility or is there perhaps a "work-around"?
You can define EOperations on that extended class that override the
getter and setter (assuming it's a single-valued feature).


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining which derived class a feature from an abstract class shall use [message #939005 is a reply to message #938971] Wed, 10 October 2012 10:43 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
Okay thanks that works. Smile
Your statement sounds like there is no possibility to use it for list or something like that, I am right?
Re: Defining which derived class a feature from an abstract class shall use [message #939039 is a reply to message #939005] Wed, 10 October 2012 11:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
John,

Try the following with Java. You'll see that Y.getX works nicely, but
Y.getXs() is an error.

import java.util.List;

public abstract class X
{
public static abstract class Y extends X
{
@Override
abstract Y getX();

@Override
abstract List<Y> getXs();
}

abstract X getX();
abstract List<X> getXs();
}

So ask yourself, how would I achieve what I want with Java? Some fancy
use of generics helps, but in the end, the APIs can still lead to class
cast exceptions at runtime that won't be noticed at compile time.


On 10/10/2012 12:43 PM, John M. wrote:
> Okay thanks that works. :)
> Your statement sounds like there is no possibility to use it for list
> or something like that, I am right?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining which derived class a feature from an abstract class shall use [message #939048 is a reply to message #939039] Wed, 10 October 2012 11:33 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
If I change the line
abstract List<X> getXs();
to
abstract List<? extends X> getXs();
it works. Smile
That would be my approach and I would describe it with Ecore, but I don't know how. The idea was to use as EType EEList, but I don't know how to pass the type of the elements.
Re: Defining which derived class a feature from an abstract class shall use [message #939060 is a reply to message #939048] Wed, 10 October 2012 11:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
John,

Comments below.

On 10/10/2012 1:33 PM, John M. wrote:
> If I change the line abstract List<X> getXs(); to abstract List<?
> extends X> getXs(); it works. :)
Yes, but consider the following:

import java.util.List;

public abstract class X
{
{
X x = null;
x.getXs().add(x);
}

public static abstract class Y extends X
{
{
Y y = null;
y.getXs().add(y);
}

@Override
abstract Y getX();

@Override
abstract List<Y> getXs();
}

abstract X getX();
abstract List<? extends X> getXs();
}

I.e., you can't add to X.getXs().
> That would be my approach and I would describe it with Ecore, but I
> don't know how.
EMF features will never be generated to look list this version of X.
getXs().
> The idea was to use as EType EEList, but I don't know how to pass the
> type of the elements.
You can define operations that look like this. If you're defining the
model with the Sample Ecore Editor you have to enabled "Show Generics"
from the menu bar and then you'll be able to create generic types with
any arbitrary structure.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining which derived class a feature from an abstract class shall use [message #939083 is a reply to message #938932] Wed, 10 October 2012 12:10 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
> Yes, but consider the following:
> I.e., you can't add to X.getXs().
That is no problem because X is abstract and shall not be added. Smile

>> The idea was to use as EType EEList, but I don't know how to pass the
>> type of the elements.
> You can define operations that look like this. If you're defining the
> model with the Sample Ecore Editor you have to enabled "Show Generics"
> from the menu bar and then you'll be able to create generic types with
> any arbitrary structure.
Thanks for your advice I found an article for it http://www.eclipse.org/articles/article.php?file=Article-Defining-Generics-with-UML-Templates/index.html.
But it seems that I can't "override" the get method of the attribute contained by the same EClass.
It seems that there is no a real practicable solution.
Re: Defining which derived class a feature from an abstract class shall use [message #939184 is a reply to message #939083] Wed, 10 October 2012 13:53 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
John,

If you define just a getXs operation in X then you can define an x
feature in Y.


On 10/10/2012 2:10 PM, John M. wrote:
>> Yes, but consider the following:
>> I.e., you can't add to X.getXs().
> That is no problem because X is abstract and shall not be added. :)
>
>>> The idea was to use as EType EEList, but I don't know how to pass the
>>> type of the elements.
>> You can define operations that look like this. If you're defining the
>> model with the Sample Ecore Editor you have to enabled "Show Generics"
>> from the menu bar and then you'll be able to create generic types with
>> any arbitrary structure.
> Thanks for your advice I found an article for it
> http://www.eclipse.org/articles/article.php?file=Article-Defining-Generics-with-UML-Templates/index.html.
> But it seems that I can't "override" the get method of the attribute
> contained by the same EClass.
> It seems that there is no a real practicable solution.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining which derived class a feature from an abstract class shall use [message #939208 is a reply to message #938932] Wed, 10 October 2012 14:26 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
> If you define just a getXs operation in X then you can define an x
> feature in Y.
I am not sure if I understood you right.
When I define an operation I have to set the return value. If I set the return value to x all deriving classes can set an subclass of x.

Furthermore the EOperation definition doesn't work like I want.
Now I have two set and one get methods. The set methods allows to use X and the second Y extends X.
It would be nice if there is only the second one.
Re: Defining which derived class a feature from an abstract class shall use [message #939216 is a reply to message #939208] Wed, 10 October 2012 14:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
John,

Comments below.

On 10/10/2012 4:26 PM, John M. wrote:
>> If you define just a getXs operation in X then you can define an x
>> feature in Y.
> I am not sure if I understood you right.
> When I define an operation I have to set the return value.
Yes.
> If I set the return value to x all deriving classes can set an
> subclass of x.
Not sure if you're talking about the list example or a single valued
feature now.
>
> Furthermore the EOperation definition doesn't work like I want.
How so?
> Now I have two set and one get methods.
Yes.
> The set methods allows to use X and the second Y extends X.
I don't follow.
> It would be nice if there is only the second one.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining which derived class a feature from an abstract class shall use [message #939243 is a reply to message #939216] Wed, 10 October 2012 15:06 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
>> If I set the return value to x all deriving classes can set an
>> subclass of x.
> Not sure if you're talking about the list example or a single valued
> feature now.
I am talking about the list example.

>> The set methods allows to use X and the second Y extends X.
> I don't follow.
Here I am talking about the single value example. I have a class A containing a list named values of X.
In class B I create the setValues EOperation and add a Parameter Y extends X.
On this way I can use with class B two setValues methods.
Re: Defining which derived class a feature from an abstract class shall use [message #939284 is a reply to message #939243] Wed, 10 October 2012 15:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
John,

I don't see any questions here so perhaps you want to reorganize your
thoughts and post a specific question focused on issue.


On 10/10/2012 5:06 PM, John M. wrote:
>>> If I set the return value to x all deriving classes can set an
>>> subclass of x.
>> Not sure if you're talking about the list example or a single valued
>> feature now.
> I am talking about the list example.
>
>>> The set methods allows to use X and the second Y extends X.
>> I don't follow.
> Here I am talking about the single value example. I have a class A
> containing a list named values of X.
> In class B I create the setValues EOperation and add a Parameter Y
> extends X.
> On this way I can use with class B two setValues methods.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining which derived class a feature from an abstract class shall use [message #939404 is a reply to message #939284] Wed, 10 October 2012 18:31 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
> If you define just a getXs operation in X then you can define an x
> feature in Y.
Please explain it more detailed. I don't understand how I can use it for my list problem.

>>> The set methods allows to use X and the second Y extends X.
>> I don't follow.
> Here I am talking about the single value example. I have a class A
> containing a list named values of X.
> In class B I create the setValues EOperation and add a Parameter Y
> extends X.
> On this way I can use with class B two setValues methods.
I search for a way to prevent the existing of the first described method.
Re: Defining which derived class a feature from an abstract class shall use [message #939792 is a reply to message #939404] Thu, 11 October 2012 03:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
John,

Comments below.

On 10/10/2012 8:31 PM, John M. wrote:
>> If you define just a getXs operation in X then you can define an x
>> feature in Y.
> Please explain it more detailed. I don't understand how I can use it
> for my list problem.
Define an operation getXs with the signature you want in X and define a
feature named "xs" in Y of type Y.
>
>>>> The set methods allows to use X and the second Y extends X.
>>> I don't follow.
>> Here I am talking about the single value example. I have a class A
>> containing a list named values of X.
>> In class B I create the setValues EOperation and add a Parameter Y
>> extends X.
>> On this way I can use with class B two setValues methods.
> I search for a way to prevent the existing of the first described method.
Please provide an example. If you use Xcore, all this will be much
simpler to describe by way of examples you can paste into your posts.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining which derived class a feature from an abstract class shall use [message #940055 is a reply to message #939792] Thu, 11 October 2012 09:14 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
>>> If you define just a getXs operation in X then you can define an x
>>> feature in Y.
>> Please explain it more detailed. I don't understand how I can use it
>> for my list problem.
> Define an operation getXs with the signature you want in X and define a
> feature named "xs" in Y of type Y.
Thanks I understood you now.
But I have a problem while implementing it with a Map.
index.php/fa/11810/0/

The picture shows my structure and my method definition.
The generated result is in class HeaderDefinitionFields:
EMap<String, HeaderDefinitionField> getValues();
and in class AbstractDefinitionFields:
Map<String, ? extends AbstractDefinitionField> getValues();


Why use EMF different maps?

StringToHeaderDefinitionField is a normal map integration like the one from the FAQ.

>>>>> The set methods allows to use X and the second Y extends X.
>>>> I don't follow.
>>> Here I am talking about the single value example. I have a class A
>>> containing a list named values of X.
>>> In class B I create the setValues EOperation and add a Parameter Y
>>> extends X.
>>> On this way I can use with class B two setValues methods.
>> I search for a way to prevent the existing of the first described method.
> Please provide an example. If you use Xcore, all this will be much
> simpler to describe by way of examples you can paste into your posts.
index.php/fa/11811/0/
The picture shows how I defined the EOperations.
getDefinition works fine, there is one method in the element called getDefinition and it returns the CommandDefinitionField.
The method setDefinition has two candidates:
index.php/fa/11812/0/
Re: Defining which derived class a feature from an abstract class shall use [message #940295 is a reply to message #940055] Thu, 11 October 2012 13:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
John,

Comments below.

On 11/10/2012 11:14 AM, John M. wrote:
>>>> If you define just a getXs operation in X then you can define an x
>>>> feature in Y.
>>> Please explain it more detailed. I don't understand how I can use it
>>> for my list problem.
>> Define an operation getXs with the signature you want in X and define a
>> feature named "xs" in Y of type Y.
> Thanks I understood you now.
> But I have a problem while implementing it with a Map.
>
>
> The picture shows my structure and my method definition.
> The generated result is in class HeaderDefinitionFields: EMap<String, HeaderDefinitionField> getValues(); and in class AbstractDefinitionFields: Map<String, ? extends AbstractDefinitionField> getValues();
The EMap data type is a wrapper for java.util.Map. You'd want a wrapper
data type for org.eclipse.emf.common.util.EMap (similar to EEList).
>
> Why use EMF different maps?
>
> StringToHeaderDefinitionField is a normal map integration like the one from the FAQ.
>
>>>>>> The set methods allows to use X and the second Y extends X.
>>>>> I don't follow.
>>>> Here I am talking about the single value example. I have a class A
>>>> containing a list named values of X.
>>>> In class B I create the setValues EOperation and add a Parameter Y
>>>> extends X.
>>>> On this way I can use with class B two setValues methods.
>>> I search for a way to prevent the existing of the first described method.
>> Please provide an example. If you use Xcore, all this will be much
>> simpler to describe by way of examples you can paste into your posts.
> The picture shows how I defined the EOperations.
> getDefinition works fine, there is one method in the element called getDefinition and it returns the CommandDefinitionField.
> The method setDefinition has two candidates:
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining which derived class a feature from an abstract class shall use [message #940347 is a reply to message #940295] Thu, 11 October 2012 14:53 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
>> The generated result is in class HeaderDefinitionFields: EMap<String, HeaderDefinitionField> getValues(); and in class AbstractDefinitionFields: Map<String, ? extends AbstractDefinitionField> getValues();
> The EMap data type is a wrapper for java.util.Map. You'd want a wrapper
> data type for org.eclipse.emf.common.util.EMap (similar to EEList).
Thanks for your advice.
My first idea was to create a EDataType with org.eclipse.emf.common.util.EMap as instance class, but I don't know what to do with it.

My second approach was to use that class as instance from a EClass, but there are a lot of methods missing, I don't think that is the right way.
Perhaps I have missed something out.
I can't find the EEList Ecore definition otherwise I would look into it.

Please provide another hint. Smile
Re: Defining which derived class a feature from an abstract class shall use [message #940360 is a reply to message #940347] Thu, 11 October 2012 15:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
John,

Load Resource... and use Browse Registered Packages to load Ecore.ecore
into some Ecore editor and look for the EEList. Note that you have to
define the two type parameters for it.


On 11/10/2012 4:53 PM, John M. wrote:
>>> The generated result is in class HeaderDefinitionFields:
>>> EMap<String, HeaderDefinitionField> getValues(); and in class
>>> AbstractDefinitionFields: Map<String, ? extends
>>> AbstractDefinitionField> getValues();
>> The EMap data type is a wrapper for java.util.Map. You'd want a wrapper
>> data type for org.eclipse.emf.common.util.EMap (similar to EEList).
> Thanks for your advice.
> My first idea was to create a EDataType with
> org.eclipse.emf.common.util.EMap as instance class, but I don't know
> what to do with it.
>
> My second approach was to use that class as instance from a EClass,
> but there are a lot of methods missing, I don't think that is the
> right way.
> Perhaps I have missed something out.
> I can't find the EEList Ecore definition otherwise I would look into it.
>
> Please provide another hint. :)


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining which derived class a feature from an abstract class shall use [message #940397 is a reply to message #940360] Thu, 11 October 2012 15:45 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
Okay I got it working so far I think, but I have to modificate a few lines of generated code.
Instead of
public EMap<String, HeaderDefinitionField> getValues()
I got following method
public EMap<String, ? extends AbstractDefinitionField> getValues()
. It is marked as error, because the system expect something else.
I can change it for my own and than it is okay, but I think there could a mistake in my ecore model.
I added the actual version:
index.php/fa/11816/0/
Re: Defining which derived class a feature from an abstract class shall use [message #940402 is a reply to message #940397] Thu, 11 October 2012 15:52 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
Oh ... I made a mistake. I have now declared the method in AbstractDefinitionFields and the values feature in HeaderDefinitionFields and it works. Smile
Re: Defining which derived class a feature from an abstract class shall use [message #940434 is a reply to message #940402] Thu, 11 October 2012 16:28 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
But I have forgotten the circumstances, that I have an unbounded upper limit. :/
With one element it works, but with unbounded upper limit I got the error that
Quote:
The return type (EList<EMap<String, HeaderDefinitionField>>) is incompatible with AbstractDefinitionFields.getValues() (EList<EMap<String, ? extends AbstractDefinitionField>>)


For better understanding I added a new picture.
index.php/fa/11819/0/

Shall I upload my model, too?
Perhaps there is just a design fail in it.
Re: Defining which derived class a feature from an abstract class shall use [message #940974 is a reply to message #940434] Fri, 12 October 2012 05:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
That looks like a Java error. You have a list of maps now. I thought
wanted the operation to return EMap<String, ? extends
AbstractDefinitionField> and for the feature to have type
EMap<String,HeaderDefinitionField>. Why do you now have a list of maps?

On 11/10/2012 6:28 PM, John M. wrote:
> But I have forgotten the circumstances, that I have an unbounded upper limit. :/
> With one element it works, but with unbounded upper limit I got the error that
> Quote:
>> The return type (EList<EMap<String, HeaderDefinitionField>>) is incompatible with AbstractDefinitionFields.getValues() (EList<EMap<String, ? extends AbstractDefinitionField>>)
>
> For better understanding I added a new picture.
>
>
> Shall I upload my model, too?
> Perhaps there is just a design fail in it.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining which derived class a feature from an abstract class shall use [message #941105 is a reply to message #940974] Fri, 12 October 2012 08:13 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
> I thought wanted the operation to return EMap<String, ? extends
> AbstractDefinitionField> and for the feature to have type
> EMap<String,HeaderDefinitionField>. Why do you now have a list of maps?
Yeah you are correct, some mistake in my thinking. Smile

Uhm ... but I have now the problem that one EClass isn't serializable anymore and it just contains basic data types.
I have looked into the EMap interface and thought perhaps there is the mistake and used instead of it the BasicEMap, makes no difference and finally it is senseless.
I have added a picture of the class hierarchy which isn't serializable. The HeaderDefinitionFieldImpl seems to be unserializable.
index.php/fa/11833/0/
Re: Defining which derived class a feature from an abstract class shall use [message #941123 is a reply to message #941105] Fri, 12 October 2012 08:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
John,

Comments below.

On 12/10/2012 10:13 AM, John M. wrote:
>> I thought wanted the operation to return EMap<String, ? extends
>> AbstractDefinitionField> and for the feature to have type
>> EMap<String,HeaderDefinitionField>. Why do you now have a list of maps?
> Yeah you are correct, some mistake in my thinking. :)
>
> Uhm ... but I have now the problem that one EClass isn't serializable anymore and it just contains basic data types.
What do you mean by it's not serializeable?
> I have looked into the EMap interface and thought perhaps there is the mistake and used instead of it the BasicEMap, makes no difference and finally it is senseless.
I don't expect you to have an attribute of type EMap.
> I have added a picture of the class hierarchy which isn't serializable. The HeaderDefinitionFieldImpl seems to be unserializable.
What do you mean by that?
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining which derived class a feature from an abstract class shall use [message #941138 is a reply to message #941123] Fri, 12 October 2012 08:38 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
>> Uhm ... but I have now the problem that one EClass isn't serializable anymore and it just contains basic data types.
> What do you mean by it's not serializeable?
I got the following exception:
Quote:
java.io.NotSerializableException: HeaderDefinitionFieldImpl


>> I have looked into the EMap interface and thought perhaps there is the mistake and used instead of it the BasicEMap, makes no difference and finally it is senseless.
> I don't expect you to have an attribute of type EMap.
I just have the EDatatype from class org.eclipse.emf.common.util.EMap or what do you want to say me?

>> I have added a picture of the class hierarchy which isn't serializable. The HeaderDefinitionFieldImpl seems to be unserializable.
> What do you mean by that?
According to the exception, it seems that there is a problem with the HeaderDefintionField.
Re: Defining which derived class a feature from an abstract class shall use [message #941158 is a reply to message #941138] Fri, 12 October 2012 08:53 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
John,

Comments below.

On 12/10/2012 10:38 AM, John M. wrote:
>>> Uhm ... but I have now the problem that one EClass isn't
>>> serializable anymore and it just contains basic data types.
>> What do you mean by it's not serializeable?
> I got the following exception:
> Quote:
>> java.io.NotSerializableException: HeaderDefinitionFieldImpl
>
Yes, modeled objects are not java.io.Serializeable...
>
>>> I have looked into the EMap interface and thought perhaps there is
>>> the mistake and used instead of it the BasicEMap, makes no
>>> difference and finally it is senseless.
>> I don't expect you to have an attribute of type EMap.
> I just have the EDatatype from class org.eclipse.emf.common.util.EMap
> or what do you want to say me?
Where is it being used?
>
>>> I have added a picture of the class hierarchy which isn't
>>> serializable. The HeaderDefinitionFieldImpl seems to be unserializable.
>> What do you mean by that?
> According to the exception, it seems that there is a problem with the
> HeaderDefintionField.
The only attributes you show are of type string and boolean.

In general your approach of asking questions involves insufficient
details to provide accurate answers and I find it frustrating.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining which derived class a feature from an abstract class shall use [message #941176 is a reply to message #941158] Fri, 12 October 2012 09:18 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
> In general your approach of asking questions involves insufficient
> details to provide accurate answers and I find it frustrating.
I am sorry, I have cleaned up my model and attached it for better understandability.
Re: Defining which derived class a feature from an abstract class shall use [message #941188 is a reply to message #941176] Fri, 12 October 2012 09:31 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
John,

I'm not a contractor for you. So giving me your model and saying please
look at it and tell me what's wrong just doesn't cut it. Focus on
something. Ask focused questions that I can answer quickly.

On 12/10/2012 11:18 AM, John M. wrote:
>> In general your approach of asking questions involves insufficient
>> details to provide accurate answers and I find it frustrating.
> I am sorry, I have cleaned up my model and attached it for better understandability.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining which derived class a feature from an abstract class shall use [message #941203 is a reply to message #941188] Fri, 12 October 2012 09:43 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
I am on the way to figure out, why I get a Java.io.NotSerializableException: HeaderDefinitionFieldImpl.
I have created a EDatatype with the instance class org.eclipse.emf.common.util.EMap, for the use of ? extends AbstractDefinitionField.

It fails while calling the method BasicEMap.writeObject(entry.getValue) on line 1530. Perhaps I shall use some other map implementation.
I adjusted the method createHeaderDefinition, that values get an instance of BasicEMap.
But I would say something is wrong with my HeaderDefinitionField in work with the BasicEMap.

StringToHeaderDefinitionField works without any problems, but with it I can't define the getValues EOperation like I have done it yet.
Re: Defining which derived class a feature from an abstract class shall use [message #941550 is a reply to message #941203] Fri, 12 October 2012 16:31 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
John,

Comments below.

On 12/10/2012 11:43 AM, John M. wrote:
> I am on the way to figure out, why I get a
> Java.io.NotSerializableException: HeaderDefinitionFieldImpl.
> I have created a EDatatype with the instance class
> org.eclipse.emf.common.util.EMap, for the use of ? extends
> AbstractDefinitionField.
Yes, likely that should be marked as serializeable false because you
can't really convert such values to and from a string...
>
> It fails while calling the method
> BasicEMap.writeObject(entry.getValue) on line 1530. Perhaps I shall
> use some other map implementation.
No, because you need EReferences to serialize references to EObjects.
> I adjusted the method createHeaderDefinition, that values get an
> instance of BasicEMap.
> But I would say something is wrong with my HeaderDefinitionField in
> work with the BasicEMap.
No, I only told you do use this type of thing to define the type of an
operation, not the type of a feature.
>
> StringToHeaderDefinitionField works without any problems, but with it
> I can't define the getValues EOperation like I have done it yet.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining which derived class a feature from an abstract class shall use [message #941777 is a reply to message #938932] Fri, 12 October 2012 21:19 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
Thanks. I got it working. Smile
You are a really great help. I would be glad if I can return the favour for your help.
Re: Defining which derived class a feature from an abstract class shall use [message #942321 is a reply to message #941777] Sat, 13 October 2012 11:52 Go to previous messageGo to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
There is only a little problem, but in this case with a single valued feature.

I defined an abstract EClass containing two methods getDefinition returns X and setDefinition takes X.
A derived EClass defines the feature definition from Type Y extends X.
The method getDefinition is correctly generated like getDefition returns Y.
But there are two methods setDefinition one takes X and the other one takes Y.
Is it possibile to say that only setDefinition for Y shall be generated?

I hope there are enough information on the first try. Smile

Some pictures can be found in my post above (http://www.eclipse.org/forums/index.php/mv/msg/398079/940055/#msg_940055).
Re: Defining which derived class a feature from an abstract class shall use [message #942382 is a reply to message #942321] Sat, 13 October 2012 13:06 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
John,

Comments below.

On 13/10/2012 1:52 PM, John M. wrote:
> There is only a little problem, but in this case with a single valued
> feature.
>
> I defined an abstract EClass containing two methods getDefinition
> returns X and setDefinition takes X.
> A derived EClass defines the feature definition from Type Y extends X.
> The method getDefinition is correctly generated like getDefition
> returns Y.
> But there are two methods setDefinition one takes X and the other one
> takes Y.
> Is it possibile to say that only setDefinition for Y shall be generated?
No. This notion of covariant return types doesn't apply for arguments.
For arguments you are defining an overloaded method. If you really are
trying to match what's done for multi-valued, in that case you can't add
to the list, so for the single valued case you should not have a set method.
>
> I hope there are enough information on the first try. :)
>
> Some pictures can be found in my post above
> (http://www.eclipse.org/forums/index.php/mv/msg/398079/940055/#msg_940055).


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO/Hibernate] Problem with Enum Attributes
Next Topic:How to populate a Map of List ?
Goto Forum:
  


Current Time: Thu Mar 28 18:56:48 GMT 2024

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

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

Back to the top