[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: Complex Map Modeling

Thanks for the detailed response! The set methods for Class1 and Class2 actually need to come from attributes.

The get method however, doesn't need to and can come from an operation.

So I guess I could make the attributes for each of the two classes and then suppress the get. I could then model a get operation for the abstract Base class and then I'd almost have it.

The only problem then is that I don't know how to make the get operation in BaseImpl abstract. I want BaseImpl to be using this get method from elsewhere in its class but the method shouldn't be implemented by BaseImpl itself - it should be implemented by the classes that extend it.

The other issue I see is that I apparently can't make the get method protected. If the abstract method was only in the BaseImpl class and not in the Base interface then that would work as well. Can that be done?

Perhaps, since the get method is nothing more than plumbing, it should not even be in the model. I am still very curious though if abstract methods and only putting methods in an Impl are possible.



Marcelo Paternostro wrote:
Hi,

There are a few considerations that I have to make before answering your question:

- You won't be able to model protected methods or attributes. The basic idea is that everything that you model is, ultimately, accessible to the clients of your code.

- As extensions of the abstract class, Class1 and Class2 inherit the get method so you don't need to defined it again on each class.

- Is there a modeled attribute for the map or are you thinking on using operations? If you are using an attribute, EMF would generate a set(Map<MyClass,?>) method in the abstract class which would conflict with the setters you want to define in the subclasses (a "Java" conflict not an "EMF" one ;-). So I will assume that you are modeling operations.

All that said, I am attaching here a project with an ecore model that has what I think you are trying to do.

Cheers,
Marcelo

Gigaplex wrote:
I have an abstract class that two other classes extend. I need a method in this abstract class like this:

protected abstract EMap<MyClass, ?> getMap();


Then, I have two classes (not abstract) that extend this abstract class that need to look like this:


Class 1
protected EMap<MyClass, ?> getMap();
public void setMap(EMap<MyClass, ADifferentClass>)

Class 2
protected EMap<MyClass, ?> getMap();
public void setMap(EMap<MyClass, SomeOtherClass>)


Is it possible to model something like this in EMF? I've modeled maps before but nothing like this.