|
|
|
Re: ecore for operation returning EList<? extends XXX> [message #431489 is a reply to message #431479] |
Mon, 13 July 2009 13:35 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------080901040609090907080608
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Chris,
Comments below.
Chris Graham wrote:
> Hello,
>
> I've been trying unsuccessfully to do something like this with
> Topcased and although I don't have a solution I thought I might just
> post what I've tried already.
>
> What I've done is create a Generic class using the following Topcased
> modelling elements:
>
> - <Class> CustomList
> |
> - <Redefinable Template Signature>
> |
> - <Classifier Template Parameter> M
> |
> - <Class> M
Hmmm. Did you read the UML2 article about how to model Ecore/Java style
generics:
http://www.eclipse.org/modeling/mdt/uml2/docs/articles/Defin ing_Generics_with_UML_Templates/article.html
>
> This creates the following java code:
>
> public class CustomList<M> extends EObjectImpl implements EObject {
No good will come if this...
>
> (you can ignore the 'extends EObjectImpl implements EObject' bit -
> that is automatically generated by EMF).
>
> Now comes that bit that's similar to your problem Gary - what I want
> to do is declare a property with type 'CustomList<ListObject>'. To do
> this I created the following Topcased model elements:
>
> - <Class> TestClass
> |
> - <Property> myProperty : InnerTestClass
> - <<eClass>><Class>InnerTestClass
>
> Where InnerTestClass was created by right clicking on the TestClass
> and selecting Create Child -> Nested Classifier -> Class.
>
> Also InnerTestClass uses an ECore::EClass stereotype and sets the
> 'Instance Class Name' property of the stereotype to
> 'CustomList<ListObject>' (it's just a string input). This created the
> following java code in TestClass:
>
> public CustomList<ListObject> myProperty;
>
> Which looks just like I want but the trouble is the ListObject class
> isn't imported into the TestClass, i.e. TestClass is missing the line:
>
> import package.ListObject;
>
> Which of course creates a compiler error. That can be fixed by just
> adding a dummy ListObject property to TestClass but that is dodgy and
> I don't want to do that.
>
> I have tried various techniques described in the article
> " http://www.eclipse.org/articles/article.php?file=Article-Def ining-Generics-with-UML-Templates/index.html",
> i.e. using eGenericType, template bindings and template parameter
> substitutions, etc but can't get anything to work the way I want it too.
I guess you did read it then. Another approach you might try is define
it directly in Ecore and then export to UML to see how it should be
represented...
>
> So my question is how can i create a property that returns the type
> 'CustomList<ListObject>' AND automatically generate the import
> statement 'import package.ListObject'?
My problem is I can't say much of anything about what's happening in
UML. Certainly this isn't difficult with Ecore. You'd defined a
CustomList EDataType, not unliked EEList, and you'd defined a ListObject
EDataType. Then you could use them to define EAttributes.
>
> -- Chris Graham
>
--------------080901040609090907080608
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Chris,<br>
<br>
Comments below.<br>
<br>
Chris Graham wrote:
<blockquote
cite="mid:980b6297594c07a0d1fd71f53a210709$1@www.eclipse.org"
type="cite">Hello,
<br>
<br>
I've been trying unsuccessfully to do something like this with Topcased
and although I don't have a solution I thought I might just post what
I've tried already.
<br>
<br>
What I've done is create a Generic class using the following Topcased
modelling elements:
<br>
<br>
- <Class> CustomList
<br>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03350 seconds