Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » parameter passing pattern for templates(Class.javajet is a specian case?)
parameter passing pattern for templates [message #531383] Tue, 04 May 2010 16:54 Go to next message
Alexey  is currently offline Alexey Friend
Messages: 36
Registered: March 2010
Member
I found one feature of emf that I would like to share (advanced emf inhabitants probably familiar with that). The parameter passing pattern for Class.javajet and for some other templates, e.g. ItemProvide.javajet or org.eclipse.emf.examples.generator.validator - those patterns are different.

In Class.javajet we have:
GenClass genClass = (GenClass)((Object[])argument)[0];
For many others:
GenClass genClass = (GenClass)argument;

And naturally using Class pattern in your own templates results in ClassCastException...

So, Ed (if it will be you), can you please comment on those differences, on design intentions? Is there something else important to know here for those who build their own templates for emf? Is this described anywhere, or only in code?

Thanks

Alexey
Re: parameter passing pattern for templates [message #531431 is a reply to message #531383] Tue, 04 May 2010 20:36 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Alexey,

If you look elsewhere in the template you can see

<%final boolean isInterface =
Boolean.TRUE.equals(((Object[])argument)[1]); final boolean
isImplementation = Boolean.TRUE.equals<(((Object[])argument)[2]);%>

The point is that we merged the Interface.javajet and Class.javajet
templates into a single template so that it would be possible to
generate separate interface and implementation classes or to generate
just a single merged result. Additional template arguments were needed
to control that. So rather than just passing a GenClass, we needed to
pass in some Booleans.


Alexey wrote:
> I found one feature of emf that I would like to share (advanced emf
> inhabitants probably familiar with that). The parameter passing
> pattern for Class.javajet and for some other templates, e.g.
> ItemProvide.javajet or org.eclipse.emf.examples.generator.validator -
> those patterns are different.
>
> In Class.javajet we have: GenClass genClass =
> (GenClass)((Object[])argument)[0];
> For many others:
> GenClass genClass = (GenClass)argument;
>
> And naturally using Class pattern in your own templates results in
> ClassCastException...
>
> So, Ed (if it will be you), can you please comment on those
> differences, on design intentions? Is there something else important
> to know here for those who build their own templates for emf? Is this
> described anywhere, or only in code?
>
> Thanks
>
> Alexey


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[EMF databinding] Problems with EMFListProperty on a single Reference
Next Topic:Lazy-loading of classes in EMF
Goto Forum:
  


Current Time: Wed Apr 24 23:39:11 GMT 2024

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

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

Back to the top