| Interface for generated EMF Interface [message #879532] |
Thu, 31 May 2012 07:30  |
Mike Moor Messages: 20 Registered: November 2010 Location: Steffisburg, Switzerland |
Junior Member |
|
|
In our project we have an EMF Model on the client side and a POJO model on our server side. we would now like to use the same interface for both models so we can easily convert between them.
Example:
Interface
public interface IPerson {
String getName();
void setName(String name);
}
Server Model
public class Person implements IPerson {
private String name;
public String getName() { return this.name }
public void setName(String name) { this.name = name }
}
Client EMF Model (generated Interface)
/**
* <copyright>
* </copyright>
*
* $Id$
*/
import org.eclipse.emf.ecore.EObject;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Person</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link Person#getName <em>Name</em>}</li>
* </ul>
* </p>
*
* @see Package#getPerson()
* @model
* @extends SerializableEObject
* @generated
*/
public interface Person extends EObject {
/**
* Returns the value of the '<em><b>Name</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Name</em>' attribute isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Name</em>' attribute.
* @see #setName(String)
* @see Package#getPerson_Name()
* @model
* @generated
*/
String getName();
/**
* Sets the value of the '{@link Person#getName <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Name</em>' attribute.
* @see #getName()
* @generated
*/
void setName(String value);
} // Person
As you can see, the EMF Model Interface Person does not extend IPerson. How can I do that? When I add it manually, it will be overridden the next time I generate my model.
Any hints?
Thanks!
Mike
|
|
|
| Re: Interface for generated EMF Interface [message #879547 is a reply to message #879532] |
Thu, 31 May 2012 07:58  |
Thomas Schindl Messages: 4462 Registered: July 2009 |
Senior Member |
|
|
You need to map your custom interface (IPerson) into EMF (by setting the
Instance Type Name) and then put it as into the supertypes of your
Person-EClass.
Tom
Am 31.05.12 13:30, schrieb Mike Moor:
> In our project we have an EMF Model on the client side and a POJO model
> on our server side. we would now like to use the same interface for both
> models so we can easily convert between them.
>
> Example:
>
> Interface
> public interface IPerson {
> String getName();
> void setName(String name);
> }
>
>
> Server Model
> public class Person implements IPerson {
> private String name;
>
> public String getName() { return this.name }
>
> public void setName(String name) { this.name = name }
> }
>
>
> Client EMF Model (generated Interface)
>
> /**
> * <copyright>
> * </copyright>
> *
> * $Id$
> */
>
> import org.eclipse.emf.ecore.EObject;
>
>
> /**
> * <!-- begin-user-doc -->
> * A representation of the model object '<em><b>Person</b></em>'.
> * <!-- end-user-doc -->
> *
> * <p>
> * The following features are supported:
> * <ul>
> * <li>{@link Person#getName <em>Name</em>}</li>
> * </ul>
> * </p>
> *
> * @see Package#getPerson()
> * @model
> * @extends SerializableEObject
> * @generated
> */
> public interface Person extends EObject {
> /**
> * Returns the value of the '<em><b>Name</b></em>' attribute.
> * <!-- begin-user-doc -->
> * <p>
> * If the meaning of the '<em>Name</em>' attribute isn't clear,
> * there really should be more of a description here...
> * </p>
> * <!-- end-user-doc -->
> * @return the value of the '<em>Name</em>' attribute.
> * @see #setName(String)
> * @see Package#getPerson_Name()
> * @model
> * @generated
> */
> String getName();
>
> /**
> * Sets the value of the '{@link Person#getName <em>Name</em>}'
> attribute.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @param value the new value of the '<em>Name</em>' attribute.
> * @see #getName()
> * @generated
> */
> void setName(String value);
>
> } // Person
>
>
>
> As you can see, the EMF Model Interface Person does not extend IPerson.
> How can I do that? When I add it manually, it will be overridden the
> next time I generate my model.
>
> Any hints?
>
> Thanks!
> Mike
|
|
|
Powered by
FUDForum. Page generated in 0.01991 seconds