Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Adapting Model Objects
Adapting Model Objects [message #423869] Wed, 08 October 2008 12:24 Go to next message
Jesse Riggins is currently offline Jesse RigginsFriend
Messages: 24
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.
--------------020200070808040308030401
Content-Type: multipart/alternative;
boundary="------------030709000805070309070002"


--------------030709000805070309070002
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

I'm still really new to EMF, so hopefully this question makes sense:

I have an EMF model similar to the attached file (first attempt at using
the UML tool so I hope it came out ok).

I'd like to make use of an object adapting facility in such a way that I
can create a method like this:

public void getCustomer(EObject object) {
//...

Customer customer = (Customer)adapterFacility.adapt(object,
Customer.class);

//...
}

so that the method could handle calls to getCustomer() with either a
Customer or Service instance. Of course I would expect to have to add
some code to at least the Service adapter to know that
Service.getCustomer() would need to be called as appropriate.

I /think/ that this type of facility is supported in the Eclipse
IAdaptable but I'm hoping to not be tied to the Eclipse runtime for my
model code. Is there any such support in EMF? Is this something that
the ItemProviderAdapters can help me out with?

Thanks,
Jesse




--------------030709000805070309070002
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
<br>
I'm still really new to EMF, so hopefully this question makes sense:<br>
<br>
I have an EMF model similar to the attached file (first attempt at
using the UML tool so I hope it came out ok).<br>
<br>
I'd like to make use of an object adapting facility in such a way that
I can create a method like this:<br>
<br>
public void getCustomer(EObject object) {<br>
&nbsp;&nbsp; //...<br>
<br>
&nbsp;&nbsp; Customer customer = (Customer)adapterFacility.adapt(object,&nbsp;&nbsp;& amp;nbsp; &nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Customer.class);<br>
<br>
&nbsp;&nbsp; //...<br>
}<br>
<br>
so that the method could handle calls to getCustomer() with either a
Customer or Service instance.&nbsp; Of course I would expect to have to add
some code to at least the Service adapter to know that
Service.getCustomer() would need to be called as appropriate.<br>
<br>
I <i>think</i> that this type of facility is supported in the Eclipse
IAdaptable but I'm hoping to not be tied to the Eclipse runtime for my
model code.&nbsp; Is there any such support in EMF?&nbsp; Is this something that
the ItemProviderAdapters can help me out with?<br>
<br>
Thanks,<br>
&nbsp;Jesse<br>
<br>
<br>
<br>
</body>
</html>

--------------030709000805070309070002--

--------------020200070808040308030401
Content-Type: image/gif;
name="exampleModel.gif"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="exampleModel.gif"

R0lGODlhpQHPAPf/AP//////1P/quuq6cpsAAHIActSbAAAAcnK66rrq/wAA mwAAANT//wCb
1Jtyuurquur/1HIAANTquv/Um5vU/wByutSbm7CwsJ18L5t7MJd4MJN3Mo51 NIlyNoNvN35s
OHlqOnRoPHBlPW1kP/j50ff41qGYbIKGgWpiP///6qCYbIKFgbpyAPj51ur/ //j41pu6upsA
cnKb1Lrq1HIAm//Uurqburq6ctT/1Lq6m9TUm+rq6gAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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4ztlNmUOb
V7/qVbCuJm5LjwbTTO/SqKca1sEaFKxwdDapYxtAaPfYwwCAkc1xI+u0HylJ vBaqSb8qprir
Gc7yvqrdFcPx/w1E2tNewZUQ0tVvjym1hC18VY+aWW/LVHxd3rLotSzudo/m 3X739Jitjfm3
7ynuY4Vcro2+XTSWGO8IH43CU88ojPceU4IdPGEZYNijwkexLcU36Bd/RHHX HOAvwDnvM4nK
DrHW7aQ23GkN/vlN13q+s4oH2+1NOBCwh33s4rb9h9M/LFePf0GNJzHzi8j4 0dv//muZ+Wfi
P69Jz5+F5Fdc+nd3AYgs7rd+eBcxA8h47JcrroZ/EKg0DZhiC9h8Cdh+FUh/ FmiAGQiA8Od/
4oeABaiA/0dBF+iAHWiCJhSBLMiCKbgYExhcL4gX/BduAliCMHiCFIiDNBiD HjODd1GD/XaD
YNOCRigtPjgoB7h/SehCQNhiOiiDPBiETchkIciEUfiDUwiFI4iBW0h2WHaE Ykh6XwgaVdhb
TwiGXYiCZfheZ8hDaWiGWaiEceiGc+iEbegWQrhxIKh+WLiGO3iFBPiBROiH gwgze32INu+H
iIWoiCJIiByYh12xh0fXiPy0iOdBiUnkiH8IiSQoiAx4h1ZoiKEIiFIIihvo iV5YhGPYimbx
hrAYX6TIhrIIFJo4PbVoi4mYi9G1i7zYXJH4i8rlisTYNMJ4jMiYjMq4jMzY jM74jNAYjdI4
jdRYjdZ4jRAREAA7
--------------020200070808040308030401--
Re: Adapting Model Objects [message #423870 is a reply to message #423869] Wed, 08 October 2008 12:27 Go to previous messageGo to next message
Jesse Riggins is currently offline Jesse RigginsFriend
Messages: 24
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.
--------------080309090201060108080502
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Oops the void return type should be Customer , but you get the idea :-) .

Jesse Riggins wrote:
> Hi,
>
> I'm still really new to EMF, so hopefully this question makes sense:
>
> I have an EMF model similar to the attached file (first attempt at
> using the UML tool so I hope it came out ok).
>
> I'd like to make use of an object adapting facility in such a way that
> I can create a method like this:
>
> public void getCustomer(EObject object) {
> //...
>
> Customer customer = (Customer)adapterFacility.adapt(object,
> Customer.class);
>
> //...
> }
>
> so that the method could handle calls to getCustomer() with either a
> Customer or Service instance. Of course I would expect to have to add
> some code to at least the Service adapter to know that
> Service.getCustomer() would need to be called as appropriate.
>
> I /think/ that this type of facility is supported in the Eclipse
> IAdaptable but I'm hoping to not be tied to the Eclipse runtime for my
> model code. Is there any such support in EMF? Is this something that
> the ItemProviderAdapters can help me out with?
>
> Thanks,
> Jesse
>
>
>
>
> ------------------------------------------------------------ ------------
>


--------------080309090201060108080502
Content-Type: multipart/related;
boundary="------------070009060501090101090104"


--------------070009060501090101090104
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Oops the void return type should be Customer , but you get the idea <span
class="moz-smiley-s1"><span> :-) </span></span>.<br>
<br>
Jesse Riggins wrote:
<blockquote cite="mid:gci8pe$o8c$1@build.eclipse.org" type="cite">Hi,<br>
<br>
I'm still really new to EMF, so hopefully this question makes sense:<br>
<br>
I have an EMF model similar to the attached file (first attempt at
using the UML tool so I hope it came out ok).<br>
<br>
I'd like to make use of an object adapting facility in such a way that
I can create a method like this:<br>
<br>
public void getCustomer(EObject object) {<br>
&nbsp;&nbsp; //...<br>
<br>
&nbsp;&nbsp; Customer customer = (Customer)adapterFacility.adapt(object,&nbsp;&nbsp;& amp;nbsp; &nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Customer.class);<br>
<br>
&nbsp;&nbsp; //...<br>
}<br>
<br>
so that the method could handle calls to getCustomer() with either a
Customer or Service instance.&nbsp; Of course I would expect to have to add
some code to at least the Service adapter to know that
Service.getCustomer() would need to be called as appropriate.<br>
<br>
I <i>think</i> that this type of facility is supported in the Eclipse
IAdaptable but I'm hoping to not be tied to the Eclipse runtime for my
model code.&nbsp; Is there any such support in EMF?&nbsp; Is this something that
the ItemProviderAdapters can help me out with?<br>
<br>
Thanks,<br>
&nbsp;Jesse<br>
<br>
<br>
<br>
<br>
<hr size="4" width="90%"><br>
<center><img src="cid:part1.07080707.04060507@jr4consulting.com"></center>
</blockquote>
<br>
</body>
</html>

--------------070009060501090101090104
Content-Type: image/gif
Content-Transfer-Encoding: base64
Content-ID: <part1.07080707.04060507@jr4consulting.com>

R0lGODlhpQHPAPf/AP//////1P/quuq6cpsAAHIActSbAAAAcnK66rrq/wAA mwAAANT//wCb
1Jtyuurquur/1HIAANTquv/Um5vU/wByutSbm7CwsJ18L5t7MJd4MJN3Mo51 NIlyNoNvN35s
OHlqOnRoPHBlPW1kP/j50ff41qGYbIKGgWpiP///6qCYbIKFgbpyAPj51ur/ //j41pu6upsA
cnKb1Lrq1HIAm//Uurqburq6ctT/1Lq6m9TUm+rq6gAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAA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AaPfYwwCAkc1xI+u0HylJ vBaqSb8qprir
Gc7yvqrdFcPx/w1E2tNewZUQ0tVvjym1hC18VY+aWW/LVHxd3rLotSzudo/m 3X739Jitjfm3
7ynuY4Vcro2+XTSWGO8IH43CU88ojPceU4IdPGEZYNijwkexLcU36Bd/RHHX HOAvwDnvM4nK
DrHW7aQ23GkN/vlN13q+s4oH2+1NOBCwh33s4rb9h9M/LFePf0GNJzHzi8j4 0dv//muZ+Wfi
P69Jz5+F5Fdc+nd3AYgs7rd+eBcxA8h47JcrroZ/EKg0DZhiC9h8Cdh+FUh/ FmiAGQiA8Od/
4oeABaiA/0dBF+iAHWiCJhSBLMiCKbgYExhcL4gX/BduAliCMHiCFIiDNBiD HjODd1GD/XaD
YNOCRigtPjgoB7h/SehCQNhiOiiDPBiETchkIciEUfiDUwiFI4iBW0h2WHaE Ykh6XwgaVdhb
TwiGXYiCZfheZ8hDaWiGWaiEceiGc+iEbegWQrhxIKh+WLiGO3iFBPiBROiH gwgze32INu+H
iIWoiCJIiByYh12xh0fXiPy0iOdBiUnkiH8IiSQoiAx4h1ZoiKEIiFIIihvo iV5YhGPYimbx
hrAYX6TIhrIIFJo4PbVoi4mYi9G1i7zYXJH4i8rlisTYNMJ4jMiYjMq4jMzY jM74jNAYjdI4
jdRYjdZ4jRAREAA7
--------------070009060501090101090104--

--------------080309090201060108080502--
Re: Adapting Model Objects [message #423871 is a reply to message #423869] Wed, 08 October 2008 12:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30806
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090509080700070704010006
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Jesse,

Comments below.

Jesse Riggins wrote:
> Hi,
>
> I'm still really new to EMF, so hopefully this question makes sense:
>
> I have an EMF model similar to the attached file (first attempt at
> using the UML tool so I hope it came out ok).
>
> I'd like to make use of an object adapting facility in such a way that
> I can create a method like this:
>
> public void getCustomer(EObject object) {
> //...
>
> Customer customer = (Customer)adapterFacility.adapt(object,
> Customer.class);
>
> //...
> }
>
> so that the method could handle calls to getCustomer() with either a
> Customer or Service instance. Of course I would expect to have to add
> some code to at least the Service adapter to know that
> Service.getCustomer() would need to be called as appropriate.
>
> I /think/ that this type of facility is supported in the Eclipse
> IAdaptable but I'm hoping to not be tied to the Eclipse runtime for my
> model code. Is there any such support in EMF? Is this something that
> the ItemProviderAdapters can help me out with?
Unless these is something more complex involved, Just doing it the plain
old Java way seems sufficient. I.e., test for instance of Customer and
instance of Service and do appropriate things for those cases...

Extending the generated XyzSwitch would do the trick too.

new XyzSwitch<Customer>()
{

Customer caseCustomer(Customer customer) { return customer}
Customer caseService(Service service) { return
service.getCustomer(); }

}.doSwitch(object);
>
> Thanks,
> Jesse
>
>
>
>
> ------------------------------------------------------------ ------------
>

--------------090509080700070704010006
Content-Type: multipart/related;
boundary="------------090900060306040309090409"


--------------090900060306040309090409
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Jesse,<br>
<br>
Comments below.<br>
<br>
Jesse Riggins wrote:
<blockquote cite="mid:gci8pe$o8c$1@build.eclipse.org" type="cite">Hi,<br>
<br>
I'm still really new to EMF, so hopefully this question makes sense:<br>
<br>
I have an EMF model similar to the attached file (first attempt at
using the UML tool so I hope it came out ok).<br>
<br>
I'd like to make use of an object adapting facility in such a way that
I can create a method like this:<br>
<br>
public void getCustomer(EObject object) {<br>
&nbsp;&nbsp; //...<br>
<br>
&nbsp;&nbsp; Customer customer = (Customer)adapterFacility.adapt(object,&nbsp;&nbsp;& amp;nbsp; &nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Customer.class);<br>
<br>
&nbsp;&nbsp; //...<br>
}<br>
<br>
so that the method could handle calls to getCustomer() with either a
Customer or Service instance.&nbsp; Of course I would expect to have to add
some code to at least the Service adapter to know that
Service.getCustomer() would need to be called as appropriate.<br>
<br>
I <i>think</i> that this type of facility is supported in the Eclipse
IAdaptable but I'm hoping to not be tied to the Eclipse runtime for my
model code.&nbsp; Is there any such support in EMF?&nbsp; Is this something that
the ItemProviderAdapters can help me out with?<br>
</blockquote>
Unless these is something more complex involved, Just doing it the
plain old Java way seems sufficient.&nbsp;&nbsp; I.e., test for instance of
Customer and instance of Service and do appropriate things for those
cases...<br>
<br>
Extending the generated XyzSwitch would do the trick too. <br>
<br>
&nbsp; new XyzSwitch&lt;Customer&gt;()<br>
&nbsp; {<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp; Customer caseCustomer(Customer customer) { return customer}<br>
&nbsp;&nbsp;&nbsp;&nbsp; Customer caseService(Service service) { return
service.getCustomer(); }&nbsp;&nbsp;&nbsp; <br>
&nbsp; <br>
&nbsp; }.doSwitch(object);<br>
<blockquote cite="mid:gci8pe$o8c$1@build.eclipse.org" type="cite"><br>
Thanks,<br>
&nbsp;Jesse<br>
<br>
<br>
<br>
<br>
<hr size="4" width="90%"><br>
<center><img src="cid:part1.09040502.00040306@gmail.com"></center>
</blockquote>
</body>
</html>

--------------090900060306040309090409
Content-Type: image/gif
Content-Transfer-Encoding: base64
Content-ID: <part1.09040502.00040306@gmail.com>

R0lGODlhpQHPAPf/AP//////1P/quuq6cpsAAHIActSbAAAAcnK66rrq/wAA mwAAANT//wCb
1Jtyuurquur/1HIAANTquv/Um5vU/wByutSbm7CwsJ18L5t7MJd4MJN3Mo51 NIlyNoNvN35s
OHlqOnRoPHBlPW1kP/j50ff41qGYbIKGgWpiP///6qCYbIKFgbpyAPj51ur/ //j41pu6upsA
cnKb1Lrq1HIAm//Uurqburq6ctT/1Lq6m9TUm+rq6gAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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FJo4PbVoi4mYi9G1i7zYXJH4i8rlisTYNMJ4jMiYjMq4jMzY jM74jNAYjdI4
jdRYjdZ4jRAREAA7
--------------090900060306040309090409--

--------------090509080700070704010006--
Re: Adapting Model Objects [message #423875 is a reply to message #423871] Wed, 08 October 2008 13:31 Go to previous message
Jesse Riggins is currently offline Jesse RigginsFriend
Messages: 24
Registered: July 2009
Junior Member
Thanks Ed,

Yes my current implementation uses the instanceof as appropriate. I'm
still learning a lot of the basics of EMF, and I was just curious to know
whether it provided an abstraction for this that I wasn't aware of. I
never considered the switch stuff, so thanks for the insight!

Ed Merks wrote:

> Jesse,

> Comments below.

> Jesse Riggins wrote:
>> Hi,
>>
>> I'm still really new to EMF, so hopefully this question makes sense:
>>
>> I have an EMF model similar to the attached file (first attempt at
>> using the UML tool so I hope it came out ok).
>>
>> I'd like to make use of an object adapting facility in such a way that
>> I can create a method like this:
>>
>> public void getCustomer(EObject object) {
>> //...
>>
>> Customer customer = (Customer)adapterFacility.adapt(object,
>> Customer.class);
>>
>> //...
>> }
>>
>> so that the method could handle calls to getCustomer() with either a
>> Customer or Service instance. Of course I would expect to have to add
>> some code to at least the Service adapter to know that
>> Service.getCustomer() would need to be called as appropriate.
>>
>> I /think/ that this type of facility is supported in the Eclipse
>> IAdaptable but I'm hoping to not be tied to the Eclipse runtime for my
>> model code. Is there any such support in EMF? Is this something that
>> the ItemProviderAdapters can help me out with?
> Unless these is something more complex involved, Just doing it the plain
> old Java way seems sufficient. I.e., test for instance of Customer and
> instance of Service and do appropriate things for those cases...

> Extending the generated XyzSwitch would do the trick too.

> new XyzSwitch<Customer>()
> {

> Customer caseCustomer(Customer customer) { return customer}
> Customer caseService(Service service) { return
> service.getCustomer(); }

> }.doSwitch(object);
>>
>> Thanks,
>> Jesse
>>
>>
>>
>>
>> ------------------------------------------------------------ ------------
>>
Previous Topic:Extending LoadResourceDialog
Next Topic:cdo (derby db) and resource import containing single quotation mark(s) in string
Goto Forum:
  


Current Time: Tue Jan 21 03:34:16 GMT 2020

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

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

Back to the top